W
W
Wood Walker2018-11-08 08:38:26
JavaScript
Wood Walker, 2018-11-08 08:38:26

How to make a cross domain request in Redux-Saga?

I installed my own project through create-react-app, installed redux-saga and everything that came with it, and I'm trying to make a cross-domain request.

Request code
fetch('https://www.metaweather.com/api/location/44418', {
      method: 'GET',
      mode: 'cors',
      headers: {
        'Content-type': 'application/json',
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Methods': 'GET',
      }


But I am getting the following error.
Mistake
5be3cab137fcb396030474.png

At the same time, earlier, I remember how I made a cross-domain request, specifying in the request only
headers: {
    'Content-type': 'text/html Access-Control-Allow-Origin: *'
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ihor Bratukh, 2018-11-08
@dollar1610

So that you do not send from the browser, if CORS is not allowed on the site where you are making the request, then nothing will work. The server request will work, I tried it from under Nodejs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question