Browse Source

解决跨域

master
taozi 3 years ago
parent
commit
730f09176e
  1. 12
      utils/request.js

12
utils/request.js

@ -71,20 +71,20 @@ function baseRequest(options) {
// 合并传参过来的 headers // 合并传参过来的 headers
// 如果接口需要登录,携带 token 去请求 // 如果接口需要登录,携带 token 去请求
console.log(options) console.log(options)
options.headers = { options.headers = {
...options.headers, ...options.headers,
// hahah: 'Bearer2 ', // hahah: 'Bearer2 ',
}
if(options.method=='post'){
options.headers.hahah='Bearer2 '
} }
// if(options.method=='post'){
// options.headers.hahah='Bearer2 '
// }
if (options.login === true) { if (options.login === true) {
options.headers = { options.headers = {
...options.headers, ...options.headers,
Authorization: 'Bearer ' + token, Authorization: 'Bearer ' + token,
} }
} }

Loading…
Cancel
Save