Ionic Storage not outputing my stored JSON data correctly - Angular

309 Views Asked by At

I have something like the following:

    Storage.remove({key: 'somedata'}).then(r => {
      Storage.set({key: 'somedata', value: data}).then(g => {
        Storage.get({key : 'somedata'}).then((val) => {
          console.log('Your json is', val);
        });
      });
    });

I get data from my API in JSON from and try to store it.

When I then try to output the stored data in the console I get the following

Picture example

I am wondering how I can get the actual data instead of it being object object

Thanks

Update - screenshot of error with potential solution:

enter image description here

2

There are 2 best solutions below

5
Wang YinXing On BEST ANSWER

In my opinion, I think you can try this

Storage.remove(key).then(r => {
   Storage.set(key, data).then(g => {
      Storage.get(key).then((val) => {
          console.log('Your json is', val);
      });
   });
});
0
AudioBubble On

I think you don't need to remove

Storage.set(key, data).then(g => {
   Storage.get(key).then((val) => {
      console.log('Your json is', val);
   });
});