添加服务类型
This commit is contained in:
@@ -19,10 +19,14 @@ service.interceptors.request.use(
|
||||
// Store 必须在拦截器内部导入,在外部导入会显示 Pinia 未初始化
|
||||
const store = useUserStore();
|
||||
// 设置请求头部 Authorization
|
||||
if(config.method=="put"){
|
||||
config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
||||
}
|
||||
if (store.token) {
|
||||
config.headers['Authorization'] = 'Bearer ' + store.token;
|
||||
//config.headers['Content-Type'] = 'multipart/form-data'
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
|
||||
Reference in New Issue
Block a user