传给后端 language
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||
import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||
import envConfig from '../../env';
|
||||
import Cookies from 'js-cookie';
|
||||
import utils from '../lib/utils';
|
||||
@@ -21,8 +21,10 @@ const api = axios.create({
|
||||
api.interceptors.request.use(
|
||||
(config: InternalAxiosRequestConfig) => {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token && config.headers) {
|
||||
config.headers['Authorization'] = `Bearer ${token}`;
|
||||
const lang = localStorage.getItem('i18nextLng') || 'zh';
|
||||
if (config.headers) {
|
||||
if (token) config.headers['Authorization'] = `Bearer ${token}`;
|
||||
config.headers['language'] = lang;
|
||||
}
|
||||
|
||||
if (!(config.data instanceof FormData)) {
|
||||
|
||||
Reference in New Issue
Block a user