$(document).ready(function () { let url = 'https://our.status.im/ghost/api/v0.1/posts/?filter=tag:nimbus&order=published_at%20desc&limit=3&formats=plaintext&client_id=ghost-frontend&client_secret=2b055fcd57ba'; var urlBase = [location.protocol, '//', location.host, location.pathname].join(''); $.ajax({ type: "get", url: url, success: function (response) { $.each(response.posts, function (index, val) { var excerpt = ''; if(val.custom_excerpt != null) { excerpt = val.custom_excerpt; }else{ excerpt = getWords(val.plaintext); } $('.contribute-wrap-blog').prepend('
'+ val.title +'

'+ val.title +'

'+ excerpt +'

Read More
'); }); } }); function getWords(str) { return str.split(/\s+/).slice(0,25).join(" "); } });