How can I properly make the following POST request?
const postWorkout = async () => {
setCompletedWorkout({
date: 31,
day: workout.mains[0].day,
exercises: completedExercises
})
try {
await axios.post('/history', completedWorkout)
} catch(error) {
throw error
}
}
I believe that it makes the request before completedWorkout is actually set as shown in the DB by an empty document: