简体   繁体   中英

I'm getting the network response, but CORS is not allowing it to enter

I'm doing an API get request via axios to an Exchange Rates API

axios.get('https://api.exchangerate-api.com/v4/latest/USD').then(res=>console.log('res',res)).catch(err => console.log('err',err))

And I'm getting the correct answer in the networkAPI请求的响应

But this is what shows on in my console for de ERR of the get request 安慰

I've researched that CORS message and all they say is, that you have to configure your server to accept the authorization header, but thats not an API to my server, it's a third party's server

What can I do?

UPDATE

I changed from "axios" from js "fetch" and it worked! I think maybe it was a default axios configuration that was causing the problem

It can't be done in a browser application(cross is only for browsers).

It is a 3rd party so the only way to send request is by not having an origin =>> Have a server(nodejs application) sending the request in there and returning the response.

You send a request to your server => server returns the response from the corss blocked => done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM