|
@@ -50,14 +50,6 @@ const errorHandler = error => {
|
|
|
return response
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 获取token令牌
|
|
|
- * @param {*} account 账号
|
|
|
- */
|
|
|
-async function apiGetToken(account) {
|
|
|
- const data = await request.get(consts.TOKEN_API, {})
|
|
|
- return data
|
|
|
-}
|
|
|
|
|
|
/**
|
|
|
* 配置request请求时的默认参数
|
|
@@ -69,6 +61,15 @@ const request = extend({
|
|
|
credentials: 'include' // 默认请求是否带上cookie
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取token令牌
|
|
|
+ */
|
|
|
+async function apiGetToken() {
|
|
|
+ const data = await request.get(consts.TOKEN_API, {})
|
|
|
+ return data
|
|
|
+}
|
|
|
+
|
|
|
// 请求拦截器
|
|
|
request.interceptors.request.use((url, options) => {
|
|
|
const token = getTokenid()
|
|
@@ -78,11 +79,11 @@ request.interceptors.request.use((url, options) => {
|
|
|
return { url, options }
|
|
|
}
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
- options.headers[consts.TOKEN_KEY] = token
|
|
|
+ options.headers[consts.TOKEN_KEY] = `bearer ${token}`
|
|
|
return { url, options }
|
|
|
}
|
|
|
+ return { url, options }
|
|
|
})
|
|
|
-
|
|
|
const refreshTokenIfNeed = async (response, config) => {
|
|
|
if (
|
|
|
response &&
|