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)

 

相关文章:

  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2021-08-17
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
猜你喜欢
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-06-27
  • 2022-12-23
相关资源
相似解决方案