Sometimes, we want to fix body data not sent with a Axios request with JavaScript.
In this article, we’ll look at how to fix body data not sent with a Axios request with JavaScript.
How to fix body data not sent with a Axios request with JavaScript?
To fix body data not sent with a Axios request with JavaScript, we can call axios.request
with an object with the data
property set to an object with the data.
For instance, we write:
axios.request({
method: 'POST',
url: `https://jsonplaceholder.typicode.com/posts`,
headers: {
'Authorization': 'token'
},
data: {
title: 'abc'
},
})
to call axios.request
with an object with the data
property set to the JSON object request payload.
The header
property has the request header data.
Conclusion
To fix body data not sent with a Axios request with JavaScript, we can call axios.request
with an object with the data
property set to an object with the data.