I am wondering what is the best way to make multiple axios requests, and reload the page after it's completed.
If using the way below, the page will reload before all the axios requests completed
const handleDeletePost= async (postId) => {
//delete multiple posts
let postToBeDeleted = selectedPostId; // it's an array containing the id of selected posts
if (postToBeDeleted.length > 0) {
postToBeDeleted.forEach(async (id) => {
const response = await PostService.deletePost(id);
console.log(response);
});
window.location.reload(); // if I put it here, the page will reload before the delete completes
}
};