axios设置请求头内容

时间:2018-06-10 18:36:14   收藏:0   阅读:1407

axios设置请求头中的Authorization 和 cookie 信息:

GET请求

axios.get(urlString, 
    {
        headers: {
            Authorization: Bearer  + token,
            "Cookie" : sessionId= + sessionId + ; recId= + recId,
            ...
        },
        params: {
            param1: string,
            param2: string
        },
        ...
    }
)
.then(res => fn)
.catch(e => fn)

POST请求

axios.post(urlString, 
    {
        data: data,
        ...
    },
    {
        headers: {
            Authorization: Bearer  + token,
            "Cookie" : sessionId= + sessionId + ; recId= + recId,
            ...
        }
    }
)
.then(res => fn)
.catch(e => fn)

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!