Answer the question
In order to leave comments, you need to log in
How to make the Content-Type header not fly away in axios post request?
Good afternoon!
axios
.post('http://api.domen/controller/action', json_obj, {
headers: {
'Authorization': 'Bearer asdasdasdadsasd=',
'Content-Type': null
}
})
.then(response => {
})
.catch(error => console.log(error));
'Content-Type': null
Answer the question
In order to leave comments, you need to log in
At the entry point to the application (main.js or index.js), set the settings for axios, for example:
In general, it's better to look at the documentation, because. perhaps this header is required for the HTTP protocol or sent automatically by the browser.
UPD: Here are different options https://github.com/axios/axios/issues/382
axios.defaults.headers.common = {};
axios.defaults.headers.common.accept = ‘application/json’;
transformRequest: [(data, headers) => {
delete headers.common['Content-Type']
return data
}]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question