美文网首页
2020-03-17 axios拦截器

2020-03-17 axios拦截器

作者: sll_ | 来源:发表于2020-03-18 17:07 被阅读0次
export function request(config) {
    const instance = axios.create({
        baseURL:'',
        timeout:5000,
    })

// axios拦截器
    //请求的时候拦截器
    instance.interceptors.request.use((config)=>{
        // console.log(config);
        //1.config中信息有没有不符合服务器的要求
        // 2.每次发送网络请求时,页面中加入请求的图标
        // 3.某些请求,验证token
        // 要返回config(仅仅参数名)
        return config
    })

    //收到时候的拦截器
    instance.interceptors.response.use()

    return instance(config)
}

相关文章

网友评论

      本文标题:2020-03-17 axios拦截器

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