Axios - 仅在 1 个调用中删除标头授权 [英] Axios - Remove headers Authorization in 1 call only

查看:55
本文介绍了Axios - 仅在 1 个调用中删除标头授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何仅在 1 次调用中删除 axios.defaults.headers.common.Authorization?

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

我正在为对我的域的所有调用设置默认值,但我在另一个域上进行了 1 次调用,如果传递了令牌,则调用会给我一个错误,当没有默认的 Auth 令牌保存时,一切正常.

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.

所以我想要做的不是在该特定调用中传递 Auth

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

我试过了,但没有用

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

我也试过 auth: {...} 但这也不起作用.解决办法是什么?谢谢

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

推荐答案

请尝试以下操作

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

这篇关于Axios - 仅在 1 个调用中删除标头授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆