Code Block Test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#postContent {
width: 75%;
margin: 0 auto;
}
code {
font-size: 1.6rem;
}
</style>
</head>
<body>
<div id="postContent">
</div>
<hr />
<code id="text1">
<pre id="codeOut">
</pre>
</code>
<script>
function displayCode(json) {
codeOut.textContent = JSON.stringify(json, '\n', 4);
}
function getPosts() {
return new Promise((resolve, reject) => {
fetch('https://www.charleskinneypiano.com/wp-json/wp/v2/posts/').then((response) => {
return response.json();
}).then((data) => {
resolve(data);
});
}).catch((err) => {
console.log(err);
});
}
getPosts().then((data) => {
let postText = data[0].content.rendered;
postContent.innerHTML = postText;
displayCode(data[0]);
console.log(data);
});
</script>
</body>
</html>