美文网首页
axios拦截器,统一加headers,请求接口

axios拦截器,统一加headers,请求接口

作者: 冬天的_太阳 | 来源:发表于2019-10-10 15:45 被阅读0次
   // 获取路由的地址
    let pathname = location.pathname;
    if(localStorage.getItem('token')){
        if(pathname != '/' &&  pathname != '/login' &&  pathname != ' ' ){
            config.headers.common['token'] = localStorage.getItem('token');
            console.log('kk');

        }else {
            // 不是登陆页面就将 header 为 null
            config.headers.common= null ;
        }
    }

相关文章

网友评论

      本文标题:axios拦截器,统一加headers,请求接口

      本文链接:https://www.haomeiwen.com/subject/nxkapctx.html