"use strict" fetch('https://earth-for-all.com/twentyseventeen/wp-json/wp/v2/posts?per_page=3') .then(data => { if (!data.ok) { throw Error(data.status) } return data.json() }) .then(posts => { var txt="" , i=0, postID=0, excerpt="" txt += "

Recent posts

" for (i in posts) { postID = posts[i].id txt += "

" txt += "
" txt += "

" + posts[i].title.rendered + "

" txt += "

Post ID: " + postID + "

" txt += "

Author: " + posts[i].author + "

" txt += "

Author Href: " + posts[i]._links['author'][0].href+"

" txt += "

Date:

" txt += "

Slug: " + posts[i].slug + "

" txt += "

Link: " + posts[i]._links['self'][0].href + "

" txt += "

Status: " + posts[i].status + "

" txt += "

Media / Thumbnail Image Link: "+posts[i]._links['wp:attachment'][0].href+"

" var pos = posts[i].content['rendered'].indexOf("") excerpt = posts[i].content['rendered'].slice(0, pos) txt += "

Excerpt:

" txt += "

" + excerpt + "

" txt += "

Content:" + posts[i].content['rendered'] + "

" txt += "
" } document.querySelector(".content").innerHTML = txt }) .catch(e => { console.log(e) })