版权声明:此文首发于我的个人站axios设置请求头内容,转载请注明出处。
axios设置请求头中的Authorization 和 cookie 信息:
GET请求1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16axios.get(urlString,
{
headers: {
'Authorization': 'Bearer ' + token,
"Cookie" : 'sessionId=' + sessionId + '; recId=' + recId,
...
},
params: {
param1: string,
param2: string
},
...
}
)
.then(res => fn)
.catch(e => fn)
POST请求1
2
3
4
5
6
7
8
9
10
11
12
13
14
15axios.post(urlString,
{
data: data,
...
},
{
headers: {
'Authorization': 'Bearer ' + token,
"Cookie" : 'sessionId=' + sessionId + '; recId=' + recId,
...
}
}
)
.then(res => fn)
.catch(e => fn)