Problems in using axios

axios:

    1. By default use json format to pass data

    2. If you want to pass FormData like $.ajax, you can use the qs.stringify method, (application/x-www-form-urlencoded)

    3. Whether it is $.ajax or qs.stringify method, like the json.stringify method, the parameter with the value of undefined in the object will be ignored by default, resulting in unacceptable background parameters (this situation has an impact: the current station wants to pass empty When the data is received, the background cannot accept it, and the undefined parameters are not processed by default.

 

Therefore, in order to avoid this situation, the transmission of parameters should be handled separately:

    1. Ordinary data: It is passed in json format by default without processing, and parameters whose value is undefined can also be passed. (application/json;charset=UTF-8)

    2. File upload: Use FormData format, including accompanying parameters can also be put into FormData (even if it is undefined, it will be passed in the past). Of course, this method can also be used in its entirety. (multipart/form-data, file upload method)

 

Guess you like

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