0

I have problem with vue axios.

I am trying to send data using get / put but I can not read it on the server side. Using POST everything works, so I do not know what the problem is. Btw. Everything works in PostMan.

axios({
    method: 'PUT',
    url: `http://example.org`,
    data:  Qs.stringify(data),
}).then(response => (console.log(response.data)))

3 Answers3

2

I am using axios PUT this way and it works well..

axios.put("http://example.org", "plaintextbodyorstringifiedmaybe", {headers: {"Content-Type": "text/plain"}}).then(response => (console.log(response.data)))
Imtiyaz Shaikh
  • 425
  • 3
  • 7
1
Vue.axios.put("http://localhost:4000/api/" + this.$route.params.id)
    .then((res) => {
     console.log(res);
Shaido
  • 27,497
  • 23
  • 70
  • 73
Saad Khawaja
  • 96
  • 1
  • 4
  • 2
    Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Jan 23 '22 at 00:47
0

An HTTP PUT response has an empty body HTTP PUT on MDN

In case of a successful request, the response body is empty, whereas a successful POST request's response has a body HTTP POST on MDN

Jost
  • 199
  • 1
  • 3
  • 16