I am having this problem with storage. I want to store an array of objects. Before storing the array I stringify it and after I retrieve it I use JSON.parse to get the data. However, I keep retrieving an array of array and the first element is the array I need. Is it possible to just one not nested array?
I am sure I am doing something wrong. Here are the functions:
Is there a reason you’re futzing around converting things to strings? I believe ionic-storage handles all that for you if you just give it an object.
That depends on whether you are actually retrieving a bunch of other things (not just these pain records), and need them all at once. In the example you give here, you are just retrieving the pain records, so Promise.all is superfluous:
this.storageProvider.retrieveRecords('painRecords').then((painrecs) => {
// painrecs should be just the object you stored
});
If you have oversimplified the example,
Promise.all([this.sp.retrieve('pain'), this.sp.retrieve('drugs'), this.sp.retrieve('notes')]).then((recs) => {
let painRecs = recs[0];
let drugRecs = recs[1];
let notes = recs[2];
});