why api calls are not working in git hub page

Viewed 34
1 Answers

I tried to replicate your code and I realized the third party api you are sending request to https://newsapi.org/v2/top-headlines?country=in&apiKey=dbddeef57b58421aafd6a26534fd9d8d

Does not allow you to send request from broswer except from localhost, thats why it works on your local machine.

Here the complete response:

{
    status: "error",
    code: "corsNotAllowed",
    message: "Requests from the browser are not allowed on the Developer plan, except from localhost."
}
Related