Axios request background can not get the solution to the parameters

Since axios sends data by default, the data format is Request Payload, not our commonly used Form Data format, and the backend may not be able to obtain it normally, so before sending, it needs to be processed by the qs module.

import qs from 'qs';
...
axios.post('url', qs.stringify({
    a: '1'
}))
.then( ... )
.catch( ... );

Implemented using axios request interceptor

axios.interceptors.request.use(function (config) {
  config.data = qs.stringify(config.data);  //qs处理
  return config;
}, function (error) {
  return Promise.reject(error);
});

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326080312&siteId=291194637