update status not updating using put request
im using form buttons to pass new status of the application the status does not update im using ut request to add udpdated status
update function
const updateApplicationStatus = async (id, newStatus) => {
let response;
try {
response = await axios.put(
`http://localhost:4000/api/v1/application/updateStatus/${id}`,
{ status: newStatus },
{ withCredentials: true }
);
} catch (error) {
if (error.response) {
toast.error(error.response.data.message);
} else if (error.request) {
console.error(error.request);
} else {
console.error("Error", error.message);
}
}
console.log("Response data:", response ? response.data : "No response received");
console.log("ID:", id);
if (response) {
const updatedStatus = response.data.application.status;
toast.success("Application status updated successfully!");
setApplications((prevApplications) =>
prevApplications.map((application) =>
application._id === id ? { ...application, status: updatedStatus } : application
)
);
}
};
New contributor
Puneet Ibarit Singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1