Site URL: https://bartlett-schenk.squarespace.com/
Hey, I seem to be having an issue appending HTML into a blog section using Post Blog Item Code Injection. What I have done is fetched the data and was looking to loop through each post and create a class to render onto the page but when I look on the console logs, it seems I am getting errors but had no issue getting the data previously.
This is the code which is also inserted in the code injection section for the main website :
<script>
fetch("https://bartlett-schenk.squarespace.com/insights?format=json-pretty")
.then( response => response.json() )
.then((data) => {
let output = '';
Object.values(data.items).forEach( (post) => {
output +=
`
<div class="insight" style="background-image: url(${post.filename})">
<h1>${post.categories[0]}</h1>
<h3>${post.title}</h3>
</div>
`
})
document.getElementsByClassName("BlogList").innerHTML = output;
})
</script>
I have also attached the logs.