Section Rendering API blocks in section on a JSON template

alexmo
New Member
1 0 2

Hi, I was trying to render a section on a product page, but I noticed that if the section has blocks and the section is in a JSON template, it renders the section but the section.blocks is empty

Replies 3 (3)
romtim
New Member
1 0 0

Same problem, 

I was wanting to include a page within a popup in another page, by using  {{ pages.test-page.content }}, but this code doesn't render content from the json template that's assigned to the page.

fedorenkossm
New Member
1 0 0

Same problem on the cart page

James_J
Tourist
12 0 2

Try to fetch the section as follows:

 

<script>
  async function renderSection() {
    var appendToBody = await fetch(`/?sections=your-section-name&optional-key=optional-value-to-pass`)
    .then(response => response.json()) // It returns a promise which resolves with the result of parsing the body text as JSON.
    .then(data => { 
      $('body').append( data["key-of-your-JSON"] ); // Append the contents to the body with JQuery
    });
  }
</script>

 

 

and then call this function.