Whenever I attempt to send a PUT request, an error pops up on the console.
export function putUserData() {
fetch(`${url}/user/${getCookie("ID")}`, {
method: "PUT",
headers: {
"Authorization": `Bearer ${getCookie("TOKEN")}`
},
body: JSON.stringify({
"first_name": userData.value.first_name,
"middle_name": userData.value.middle_name,
"last_name": userData.value.last_name
})
}).then(response => {
if (response.ok) {
return response.json()
}
switch (response.status) {
case 400:
console.log("Incorrect data");
break;
}
}).then(data => {
router.push("/auth");
console.log(data);
}).catch(err => {
console.error("Cannot fetch" + err);
});
}
Viewing the network request on the console:
An error message is displayed in the console:
I'm puzzled as to why it's failing to send a request, especially when post requests go through without any issues.