const [isBookingDone, setIsBookingDone] = useState(false);
const [isError, setIsError] = useState(false);
const [errorMessage, setErrorMessage] = useState(”);
const slotBooking = async (slotTiming, bookedDate, userId) => {
let config = {
url: `http://localhost:3005/api/bookings`,
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
},
data: {
‘slotTiming’: slotTiming,
‘bookedDate’: bookedDate,
‘userId’: userId
},
};
await axios(config).then((res) => {
loadBookingData();
setIsBookingDone(true);
}).catch((e) => {
setIsError(true);
setErrorMessage(e.response.data.message);
})
return ‘success’;
}