Problem Description:
Vue uses Axios to submit a POST request, the request address and parameters are correct, but has been reported missing parameters of the error
Explore: compare POST request data, submit data in the wrong way
(1) Axios POST request (return response missing parameter)
(2) Ajax POST request (successful return result)
Solution: Add the Axios request Interceptor, modify the request header of the POST request and the request parameter processing mode
Import qs from ' QS ';/*Request Interceptor*/axios.interceptors.request.use (config)= { if(Config.method = = = ' Post ') {config.headers[' Content-type '] = ' application/x-www-form-urlencoded; Charset=utf-8 '; Config.transformrequest= [function(data, headers) {returnqs.stringify (data); }]; } returnconfig;}, (Err)= { returnPromise.reject (err);});
Axios POST Request Error