Axios - Remove headers Authorization in 1 call only

Try the following

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

To send a request without:

  • Modifying global axios defaults
  • Creating a new axios instance

Change your request similarly to this:

axios.get('http://example.com', {transformRequest: (data, headers) => {
    delete headers.common['Authorization'];
    return data;
  }
});

The answer I was looking for was posted in the comments of Apurva jain's answer, but hasn't been made an individual answer, so I've posted it separately for easy reference :)


if you already have a default 'Authorization' for all requests you can create an instance for that specific request

var instance = axios.create();
delete instance.defaults.headers.common['Authorization'];

instance.get("http://api.com");

Tags:

Axios

Vuejs2

Vuex