How to remove a SQLite storage item which is populated using forEach()

Hello guys,

I’m using Ionic storage. I have two pages. The first page is for saving items to favorite list.
The second page is a list of favorite items which has delete function.
I added several items using this command on the first page. ${ }, this.item;

The first page is linked to dataProvider. This saves item with key: item {{ item’s id number ]} to SQlite storage along with all of its attributes from dataProvider.

On the second page, I’m fetching all saved items from storage to a list using below command:

  ionViewDidLoad() { (item) => {

and this can fetch all items from storage with *ngFor directive and {{ }}, {{ item.description }}

I’m trying to delete the item using: ${ });
However it throws me an error:
Cannot read property 'id' of undefined

How can I work around this? this delete command works well on the first page which has imported dataProvider.
The second page is fetching items using interface and storage.

export interface StorageItem {
    name: string,
    description: string,
   id: nubmer;

I’m using *ngFor="let item of StorageItems" on second page.

this.storageItems.splice(index, 1);
didn’t work… I’ve tried this.storageItems.pop() as well. None of them can erase an item from favorite list although items can be erased from the first page which received item’s attributes directly from the dataProvider.

What am I missing here?
Any help would be appreciated!

Thanks in advance

still no solution for this… any advice would be appreciated.

Can you just set each item by Id?

storage.set(`${}`, item)

And fetch by

The way your code looks, it appears you’re using a combo of the item itself + its Id where it should just be the item Id as a string.



Could / should work

1 Like

Thanks for your response.

I’m still getting the same error message: “Cannot read property “id” of undefined”
It looks like the page which is fetching items from the storage is not able to pass in id to function… any other opinion would be appreciated.