Scene 1:

Back end: Json transfer, put in Body (Body pass parameter).

Front end:

  1. Json transfer generally means that the back end expects our request’s Content-type to be set to Application/JSON.

  1. Body passes the parameter, and the backend uses req.body to get it. The effect seen in the Chrome debugger is the parameter in the corresponding Request Payload

Scene two:

Back end: To use post request, parameter form to pass the parameter

Front-end: parameter there are also two kinds of parameter transmission

  1. The first is get, where the parameters are placed after the URL and are retrieved using req.query at the back end. Such as:

Corresponding to network is the parameter in the Query String Parameters here

  1. The second one is request-header, where the content-type is
  • multipart/form-data
  • application/x-www-form-urlencoded

Req.query is also used on the back end to retrieve parameters from the Form Data column:

Preview the request

The most common way to precheck a request is when we set the content-Type in Axios itself instead of one of the following:

  • text/plain
  • multipart/form-data
  • application/x-www-form-urlencoded

For example, in scenario 1, application/ JSON, the browser will first send an Options precheck request, and only if the precheck request passes, will it continue to send our real request.

However, if the access-Control-allow-methods backend does not contain OPTIONS, CORS cross-domain errors will occur.

An example of back-end configuration: