Vue project axios post method parameter passing background does not receive parameters

Look, axios.post format transmission parameters

A closer look, Content-Type is application / json type, this type of data we need to become  application / x-www-form- urlencoded this type of background to get reception

 

:( a way to use qs)

Use qs module, you use the axios, you do not install a separate module qs matter, because this library contains axios

 

first step:

 

Step two:

 

 

Note :( da da da)

In this case, Content-Type is like this

 

And this:

Data type (like this background will receive the):

 

 

 

Second way (using URLSearchParams)

                let data = new URLSearchParams();
                data.append('username',  this.username)
                data.append('password',  this.password)

 

Precautions: Look ---> da da da <--- this flag, the situation is the same

 

Three ways (string form)

let data = "username=" + this.username + "&password=" + this.password;

 

Precautions: Look ---> da da da <--- this flag, the situation is the same

 

Guess you like

Origin www.cnblogs.com/oukele/p/12670757.html