133
rated 0 times
[
140]
[
7]
/ answers: 1 / hits: 19178
/ 7 Years ago, wed, december 6, 2017, 12:00:00
axios.put method doesn't work while axios.post works.
This is working example for post request. (example)
let response = await axios.post(`${ROOT_URL}/urls/url/`, {
post_id,
password,
content
}, { headers });
console.log(response.status) // 201.
I just copied and pasted the valid post request, and modified some fields and method for put
request. But it returns 400 error on server side.
let response = await axios.put(`${ROOT_URL}/profile/update/`, {
title,
gender
}, { headers }); <- Server prints 400 HTTP error.
I tested with Postman
and I confirmed that it works with put method. I have to think that my syntax for axios.put is wrong but I'm not sure how it can be different with the post method.
If you see axios's official doc page, it looks almost identical. Axios documentation link
And axios version is 0.16.2 : axios: ^0.16.2,
More From » reactjs