diff --git a/ionic/platform/storage/storage.ts b/ionic/platform/storage/storage.ts index b1530c2339..2299b3a9bd 100644 --- a/ionic/platform/storage/storage.ts +++ b/ionic/platform/storage/storage.ts @@ -20,12 +20,14 @@ export class Storage { return this._strategy.get(key); } getJson(key) { - try { - return JSON.parse(this._strategy.get(key)); - } catch(e) { - console.warn('Storage getJson(): unable to parse value for key', key,' as JSON') - return null; - } + return this.get(key).then(value => { + try { + return JSON.parse(value); + } catch (e) { + console.warn('Storage getJson(): unable to parse value for key', key, ' as JSON'); + throw e; // rethrowing exception so it can be handled with .catch() + } + }); } set(key, value) { return this._strategy.set(key, value);