Article From:

I do the login function, the front desk sends the post request to the nodejs server with Vue and Axios, the sending way is like this:

Then I receive the background, reasonably direct req.body.userName can get the username, but to req.req.body.userName to get, then back to the front desk to return data is also directly to the res.json is not aFunction

Answer 0:

Because you (‘login’, function)res, req, next) ) The reverse is written according to the rule that req is in front and res is behind.

Answer 1:

First, add one at the time of Axios submission

    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'

Second, convert your data to qs.stringify (data) and remember to import QS packages.

Leave a Reply

Your email address will not be published. Required fields are marked *