I am making a PUT request using Axios (Node.js) to my API. Through debugging, I receive the response that everything went correctly, but the field I wish to alter does not change. I did the autorization on Strapi config to allow put method as public users, feel free to try it.
code in Next.JS
useEffect(() => {
const incrementViewCount = async () => {
console.log("incrementViewCount called");
console.log(`Count: ${attributes.Count}`);
const newCount = 8;
setCount(newCount);
const url = `http://144.22.167.20:1337/api/contos/${postData.Id}`;
console.log(
`Making PUT request to URL: ${url} with newCount: ${newCount}`
);
await axios({
method: "PUT",
url: url,
headers: {
"Content-Type": "application/json",
// Authorization: `Bearer ${yourToken}`,
},
data: {
data: {
attributes: {
Count: newCount,
},
},
},
})
.then((response) => {
console.log("Success response:", response);
})
.catch((error) => {
console.error("Error in PUT request:", error);
});
The response is 200, on API log, it returns th api being called with PUT Method,
Can anyone gimme an idea?
console.log("PUT request completed");
};
incrementViewCount();
}, []);