[Vuejs]-How to add HEADERS in vuejs with api keys using AXIOS, for a GET request to a RESTFULL API

1👍

If you are trying to set the headers globally, you can do something like the following in your main.js:

import axios from 'axios';
axios.defaults.headers.common['Authorization'] = token;

For more information, see:
https://github.com/axios/axios#global-axios-defaults

0👍

Try using this syntax

axios.get(your url here,{
       headers:{
            your headers here
}
})
.then((res)=>{
    //do something
})
.catch((err)=>{
 //do something
})

Leave a comment