Closed Q8hma closed 5 years ago
Why use async
like this?
.then(async ret => {
Why use
async
like this?.then(async ret => {
it was test and i forgot to remove it
redux + redux-persist
should fit your scenario perfectly IMO.return
before storage.xxxx
for example:
export async function loadData(id) {
+ return storage.load({
thnx for your help i got little issue on one function
export async function addData(item,id) {
return storage
.load({
key: 'items',
id:id
})
.then(ret => {
storage.save({ key: 'items',id:id, data: {...ret,count:(ret.count+1)} });
return {status:"good",msg:"update"};
}).catch(err => {
storage.save({ key: 'items',id:id, data: item });
return {status:"good",msg:"new"};
});
}
it not add 1 it add 2 , every time i call it it count+2
I did not see how you retrieved the updated data (btw, data are already plural so no datas
). Besides, your code style and indentation are really bad, which is easy to make mistakes and difficult for other people to review. You really need to use prettier
and eslint
to clean up your code.
thnx bro , got the error 👍 :) ... i call the add 2 time
i want to ask you how to donation ??
Thanks for your kindness. Currently it's too troublesome to accept donation.
this is my code cart file:
render file :
the code not save or load any data