forked from natuka/web.puabadge.com
代码提交
This commit is contained in:
1 parent
c30768d605
commit
b52dcc0842
14 files changed
+3997
-38
No files matched your search
@@ -50,18 +50,18 @@ const errorHandler = (error: RequestError): Promise<any> => {
|
||||
|
||||
// 请求拦截器
|
||||
const requestHandler = (config: InternalAxiosRequestConfig): InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig> => {
|
||||
// const savedToken = localStorage.get(STORAGE_TOKEN_KEY)
|
||||
// 如果 token 存在
|
||||
// 从 localStorage 读取 code(刷新时也能获取到)
|
||||
const code = localStorage.get('code')
|
||||
const trialCode = localStorage.get('trialCode')
|
||||
const userId = localStorage.get('userId')
|
||||
|
||||
// 让每个请求携带自定义 token, 请根据实际情况修改
|
||||
if (code)
|
||||
if (code) {
|
||||
config.headers['Authorization'] = code
|
||||
if (trialCode)
|
||||
config.headers['Authorization'] = trialCode
|
||||
if (userId)
|
||||
}
|
||||
if (userId) {
|
||||
config.headers['Userid'] = userId
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user