We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Apr 29, 2020 1:01 PM
Hi Mates,
I am trying to integrate the 3rd party REST API in our HubSpot custom module. So that I thought to access it on my webpage.
For Ex: https://via.ritzau.dk/json/v2/releases --> Is my 3rd Party REST API
Using postman service, I’ve generated the below code and integrated it into one of our webpages. But it was returning an error by saying that, it has been blocked by CORS policy (please refer to the below error image).
Can anyone help me out here?
Code :
var settings = {
"url": "https://via.ritzau.dk/json/v2/releases",
"method": "GET",
"timeout": 0,
};
$.ajax(settings).done(function (response) {
console.log(response);
});
Thanks,
Sanjay
Aug 20, 2020 1:53 PM
Try putting this in front of your url string
https://cors-anywhere.herokuapp.com/
to make it like this:
https://cors-anywhere.herokuapp.com/https://via.ritzau.dk/json/v2/releases
that fixes the error...
Apr 30, 2020 4:30 AM - edited Apr 30, 2020 4:31 AM
Hey @sjay,
Could you try removing the code and see the error is still showing?
Generally, as Connor mentioned on this community thread:
"this means your domain is blocking these requests since it violates the CORS rules set by the browser. It's blocking them because your domain you're requesting from differs from the one you're requesting to. This does a much better job of explaining this than I can: https://stackoverflow.com/questions/20035101/why-does-my-javascript-get-a-no-access-control-allow-or..."