Axios - Remove headers Authorization in 1 call only

user7021169 picture user7021169 · Oct 10, 2017 · Viewed 21k times · Source

How can I remove the axios.defaults.headers.common.Authorization only in 1 call?

I'm setting the default for all the calls to my domain but I have 1 call that I make on another domain and if the token is passed the call gives me an error, when there's no default Auth token saved everything works fine.

So what I'm trying to do is not pass the Auth in that specific call

I tried this but it doesn't work

    loadApiCoins({ commit }) {
        Vue.axios({
            method: 'get',
            url: 'https://api.coinmarketcap.com/v1/ticker/',
            headers: {
                'Authorization': '',
            },
        }).then(...)
    },

I also tried auth: {...} but that doesn't work either. What's the solution? Thanks

Answer

Apurva jain picture Apurva jain · Oct 10, 2017

Try the following

delete axios.defaults.headers.common["Authorization"];
// or which ever header you have to remove