不需要登录的接口,取消增加Authorization 字段

This commit is contained in:
Gaoxs
2020-11-11 23:33:39 +08:00
parent 0da5ca0077
commit 0c52c12c6c

View File

@ -42,7 +42,7 @@ fly.interceptors.response.use(
handleLoginFailure(); handleLoginFailure();
return Promise.reject({ msg: "未登录", toLogin: true }); return Promise.reject({ msg: "未登录", toLogin: true });
} }
if (error.response.data.status == 5109) { if (error.response.data.status == 5109) {
uni.showToast({ uni.showToast({
title: error.response.data.msg, title: error.response.data.msg,
icon: "none", icon: "none",
@ -62,9 +62,16 @@ function baseRequest(options) {
// 合并传参过来的 headers // 合并传参过来的 headers
// 如果接口需要登录,携带 token 去请求 // 如果接口需要登录,携带 token 去请求
options.headers = { options.headers = {
...options.headers, ...options.headers
Authorization: "Bearer " + token }
if (options.login === true) {
options.headers = {
...options.headers,
Authorization: "Bearer " + token
}
} }
// 如果需要登录才可访问的接口没有拿到 token 视为登录失效 // 如果需要登录才可访问的接口没有拿到 token 视为登录失效