Jump to content

Appending HTML into a class

Recommended Posts

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



  		.then( response => response.json() )
  		.then((data) => {
      		let output = '';
      		Object.values(data.items).forEach( (post) => {
    			output += 
						<div class="insight" style="background-image: url(${post.filename})">
      		document.getElementsByClassName("BlogList").innerHTML = output;


I have also attached the logs.


Screen Shot 2021-06-01 at 13.23.40.png

Link to comment
  • Replies 0
  • Views 214
  • Created
  • Last Reply


This topic is now archived and is closed to further replies.

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.