nick
nick

Reputation: 3227

Axios request not sending payload when I use axios({...});

enter image description here

To me, this code is the same, however in Chrome Dev Tools, the first request has the payload set:

enter image description here

But the second doesn't. Any ideas?

Upvotes: 0

Views: 1370

Answers (1)

Đăng Khoa Đinh
Đăng Khoa Đinh

Reputation: 5411

Based on an example from Axios Github page, the data property contains the payload

// Send a POST request
axios({
  method: 'post',
  url: '/user/12345',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  }
});

So, in your second request, you should change body to data

Upvotes: 2

Related Questions