已解决,nodejs 使用axios时,data参数转为query形式才行- // 添加请求拦截器
- axios.interceptors.request.use(
- (config: AxiosRequestConfig) => {
- if (config.method === 'post' && config.headers['Content-Type'] !== 'multipart/form-data') {
- config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
- config.data = qs.stringify(config.data);
- }
- // config.headers.Cookie = db.get('cookie').value();
- console.log(config, 'config');
- return config;
- },
- (error: AxiosError) => {
- // 对请求错误做些什么
- return Promise.reject(error);
- },
- );
复制代码
|