hello guys i am working with a react native project i am working with offline so i have to store data offline and when the internet is back i must redirect the user to a screen and send data to web and change a percentage but my problem is that the fetch render twice and the data returned after all promis is undefined and the fetch to server passed by the way in server and data base is changer well
here is my functions
export const syncOfflinedata = activities => {
return dispatch => {
Promise.all(
activities.map(item => {
Api()
.put(putEvaluation(item._id), {evaluation: item.evaluation})
.then(data => {
dispatch(setProgressporcentage(1 / activities.length));
})
.catch(err => {
console.log(err.message);
});
}),
)
.then(datafinished => {
console.log('finished', datafinished);
})
.catch(e => {
console.log(e);
});
};
};