0

When I request something it comes up with 3 errors.

I think it doesn't allow me to do a request from specific places but I am not sure I am pretty new to requests and I want to put this in my content script. the 3 errors

I tried doing it on other places but it didn't work, I expected to get a JSON response back.

And also if I just go to the link it gives me the info I need, if the only way to do it is through background page in my web extension then that's fine but I prefer it on the content script.

  • Hi, welcome to Stack Overflow! [Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551/8289918) It makes it harder for others to read your code, reproduce the scenario, and answer your question. [Edit] your question to include your code [formatted as code blocks](https://meta.stackoverflow.com/q/251361/8289918). – Lauren Yim Apr 06 '22 at 05:13
  • You've to give a permission for that URL in the manifest file of the extension. That is, include the URL in `permissions` array. – Teemu Apr 06 '22 at 05:13

1 Answers1

-1

It is a CORS error that is Cross-Origin Resource Sharing, that means you are requesting a url which has only allowed a certain other URLs to consume its resources. Try adding Moesif Cors extension to google chrome and then request the API, this extension bypass the CORS policy. If it doesn't, that means you cannot hit that API, outside access to resource is restricted.

Ritik Banger
  • 2,107
  • 5
  • 25
  • Oh okay there are stuff that can bypass it, that's cool, but if it doesn't work is there any chance it will work on a background page? –  Apr 06 '22 at 05:04
  • It is doesn't bypass it that means you cannot hit that API, outside access to resource is restricted. No chance for it to work, it is restricted by a policy that is accepted globally. – Ritik Banger Apr 06 '22 at 05:06