Getting error to use the hubspot blog api in hubspot custom html module via javascript

Regular Contributor
<script type="text/javascript">
$(document).ready(function() { 
 
$.ajax({
        url: 'https://api.hubapi.com/content/api/v2/blog-posts?hapikey=demo&limit=100&state=PUBLISHED',
    type: 'GET',
    dataType: 'json',
success: function() { console.log("Success"); },
error: function()   { console.log('Failed!'); }

});
});


</script>
Reply
0 Upvotes
3 Replies 3
HubSpot Employee

@Raman_verma The request has to be made server side.

Reply
0 Upvotes
Regular Contributor

@pmanca yes obvious request is on server side I have added the code in HUBSPOT Custom html module …

Please read the title of the topic where I have mentioned that I am using hubspot website page where I have placed this code in custom html module

Reply
0 Upvotes
HubSpot Employee

@Raman_verma The code you posted is JQuery which is client-side. Also for the record a hubspot website page is client side as well. Also I received the error you sent Takeaki Fujita which tells me as well its a CORS request issue and that you are making it client side.

Reply
0 Upvotes