0

So I tried to host a little project I made in React.

GitHub GitHub Pages

But, everytime I try to send a request to MetaWeather, I get this back. Error

I don't know what I should be doing different. I used Axios, but even with Fetch the same thing happens.

  • 1
    Please post code, errors, sample data or textual output here as plain-text, not as images that can be hard to read, can’t be copy-pasted to help test code or use in answers, and are barrier to those who depend on screen readers. You can edit your question to add the code in the body of your question. For easy formatting use the `{}` button to mark blocks of code, or indent with four spaces for the same effect. The contents of a **screenshot can’t be searched, run as code, or copied and edited to create a solution.** – tadman Sep 26 '20 at 23:09
  • 1
    I can't read anything in that screenshot. It's just too tiny. – tadman Sep 26 '20 at 23:09
  • 1
    Does this answer your question? [Is there a way to enable CORS on Github pages?](https://stackoverflow.com/questions/18923328/is-there-a-way-to-enable-cors-on-github-pages) – tadman Sep 26 '20 at 23:10
  • 1
    I think you'll have to ask MetaWeather to add the CORS headers to their API, if they're happy for you to use it from web apps. I don't think this is something you can change in your code. The answer may well be that they don't want you do this, or don't support it. – Rup Sep 26 '20 at 23:27
  • @tadman Nope, if it was working like that, it should not be a problem, right? – Miguel Angel Guerrero Salinas Sep 27 '20 at 00:44
  • 1
    @tadman Also sorry, I guess I got caught up and tired from doing this, I'm legitimately sorry. – Miguel Angel Guerrero Salinas Sep 27 '20 at 00:44
  • @Rup Looks like that's the case. But there's no way to know before hand, right? – Miguel Angel Guerrero Salinas Sep 27 '20 at 00:45
  • 2
    You can use https://cors-anywhere.herokuapp.com/ but remember it should be enabled from there side also. – Vaibhav Rai Sep 27 '20 at 03:23
  • 1
    At the end I used your solution @VaibhavRai, thank you! – Miguel Angel Guerrero Salinas Sep 28 '20 at 14:26
  • 1
    @MiguelAngelGuerreroSalinas glad it helped you, I am adding it as an answer then :). – Vaibhav Rai Sep 29 '20 at 03:20

1 Answers1

2

You can use https://cors-anywhere.herokuapp.com/ but remember it should be enabled from there side also

Vaibhav Rai
  • 168
  • 1
  • 8