-2

Is there anyway I can solve this error? I have tried putting " " and also in the request header, but it doesnt work

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

axios.post("https://platform.fatsecret.com/rest/server.api?food_id=33691&method=food.get.v2&oauth_consumer_key=9a1a6fd1fff5433f9dd77daa4587bf5d&oauth_nonce=1234&oauth_signature=sAyYTJiIxOGkvFpBcH8L%2BlFQRCQ%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1245126631&oauth_version=1.0",{
            })
            .then(response=>{
                console.log(response.data);

                }
            
            )
            .catch(error=>{
                alert("wrong");
                console.log(error)
            })
Yi Kiat
  • 441
  • 1
  • 4
  • 6
  • Search on SO and you will find plenty of similar questions for that exact same problem/error – Andreas Oct 14 '21 at 11:12
  • Does this answer your question? [Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?](https://stackoverflow.com/questions/20035101/why-does-my-javascript-code-receive-a-no-access-control-allow-origin-header-i) – Martin Zeitler Oct 14 '21 at 11:15
  • `fatsecret.com/rest/server.api` does not permit direct embedding of their data. – Martin Zeitler Oct 14 '21 at 11:16

1 Answers1

-1

Usually, You need to allow it from the server side. Otherwise, you will get this error.

arpanexe
  • 52
  • 6