0👍
The this.goBack()
isn’t properly waiting for the async function to finish. The this.delete(id)
line below and the this.goBack()
lines are executed in parallel as the delete
is an async call.
Also on a side note, you can also use a try...catch
block instead of using the promise chaining. Look at my changes below:
async deleteProvider(id){
let c = confirm("Do you really want to delete it? You will not be able to restore this data again!")
if(c){
try{
const success = await this.delete(id)
return success;
} catch(error){
return error;
} finally {
this.goBack(); // If you want to go back only on success, move this line inside the try block before the `return`.
}
}
}
Source:stackexchange.com