xxxxxxxxxx
axios.defaults.headers.post['header1'] = 'value' // for POST requests
axios.defaults.headers.common['header1'] = 'value' // for all requests
xxxxxxxxxx
let config = {
headers: {
header1: value,
}
}
let data = {
'HTTP_CONTENT_LANGUAGE': self.language
}
axios.post(URL, data, config).then( )
xxxxxxxxxx
let instance = axios.create({
headers: {
post: { // can be common or any other method
header1: 'value1'
}
}
})
//- or after instance has been created
instance.defaults.headers.post['header1'] = 'value'
//- or before a request is made
// using Interceptors
instance.interceptors.request.use(config => {
config.headers.post['header1'] = 'value';
return config;
});