I hope this codebase helps you to solve the problem.
async function sendBookingRequest() {
setIsLoading(true); // Start loading before making the request
try {
const response = await axios.post(
"https://danilo2588.pythonanywhere.com/book",
{
requested_date: date,
hours: bookedHours,
business: cancha,
phone: cellphone,
},
{
headers: {
Authorization: "1234567890123456789012345678901234567890",
},
}
);
setConfirmation(response.data); // Handle successful response
setStepper(7);
} catch (error) {
console.log(error); // Log or handle the error
} finally {
setIsLoading(false); // Stop loading after the request
}
}
And you can refer this documentation for axios configuration. https://axios-http.com/docs/post_example
Thanks