When attempting to use the storage get method to fill the array storedArr = []
, I encounter the error message .push is not a function
:
storedArr = this.storage.get('stored') ? this.storage.get('stored').then((e) => {e}) : [];
The crucial section of my code looks like this:
import { Storage } from '@ionic/storage';
export class MyPage {
constructor(
private storage: Storage) {
}
// storedArr = []; This approach works but resets the array
storedArr = this.storage.get('stored') ? this.storage.get('stored').then((e) => {e}) : [];
saveToStorage() {
this.storedArr.push({ // .push is not a function
title: 'blabla',
body: 'more blabla'
});
this.storage.set('stored', this.storedArr);
}
}
How can I modify that section of the code for it to work properly?