APIs & Integrations

ramanverma2005
Participant

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

<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>
0 Upvotes
3 Replies 3
3PETE
HubSpot Employee
HubSpot Employee

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

@Raman_verma The request has to be made server side.

0 Upvotes
ramanverma2005
Participant

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

@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

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

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

@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.

0 Upvotes