axios.defaults.headers.common['authetication']=token; code example
Example 1: axios default headers authorization
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
Example 2: axios defaults headers common
axios.get('/user?ID=12345')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
axios.get('/user', {
params: {
ID: 12345
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Example 3: axios defaults headers common
axios({
method: 'get',
url: 'http://bit.ly/2mTM3nY',
responseType: 'stream'
})
.then(function(response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});