当前位置: 首页 > Web前端 > vue.js

vue-axios设置请求头

时间:2023-03-31 20:13:21 vue.js

axios在请求头中设置Authorization和cookie信息:GETrequestaxios.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)