How can we store data in storage using Capacitor JS with Angular?

RMAG news

I read this documentation, which is capacitor JS provided

This is my code for storing the data in capacitor js.

`/*

this function is used for the set Value
*/
async setUser(data: any) {
await Preferences.set({
key: ‘value’,
value: JSON.stringify(data)
});
}

/*

this function is used for the get-Value
*/
async getUser() {
const user: any = await Preferences.get({ key: ‘value’ });
this.UsersDetails = user.value;
}`
This is working fine when my app is running in the background. When I trash my app in the background and call for getUser(). It’s giving a null value. It’s not work.

Can anyone suggest if I am missing anything, or is there any other way available to Store the data in Capacitor JS?

Leave a Reply

Your email address will not be published. Required fields are marked *