Axios cross-domain request. The front-end response cannot receive data.

in a cross-domain request, a get request from axios sent two requests for options and get

use .then (response = > console.log (response.data)) to output the result returned in the background, but you can see the return of the get request

in the browser console.

clipboard.png

how does axios get the data returned by the following get request

May.22,2021

1. If there is a custom header, in the request, a pre-request with the method of options will be sent before sending the real request, which is used to test whether the server can accept the real request.
2. Cross-domain requests don't get response in the first place.


is the correct way to write


Why not try printing the value of response, maybe.


will be posted back. Cross-domain requests can also request data if they are not set to allow cross-domain, but you cannot get the request data in the code.

Menu