I have managed to loop out all content from a specific ContentType and everything works well except that the entries are not followed by their specific assets.
In this specific case it renders as: Entry 1 Entry 2 Entry 3 Asset 1 Asset 2 Asset 3
I want it to render as: Entry 1 Asset 1, Entry 2 Asset 2 etc...
Putting the asset array loop inside the fields loop didn't help :)
Javascript
client.getEntries({
include: 1,
'content_type': 'posts'
})
.then((response) => {
var template = $('#myEntries').html();
var html = Mustache.to_html(template, response.toPlainObject());
$('.result').html(html);
})
.catch((error) => {
console.log('Error occured')
console.log(error)
})
HTML
<script id="myEntries" type="text/template">
{{#items}}
<h1>{{fields.header}}</h1>
<p>{{fields.description}}</p>
{{/items}}
{{#includes.Asset}}
<p>File: <img src="https:{{fields.file.url}}?fit=thumb&f=top_left&h=200&w=200" width="100"/></p>
{{/includes.Asset}}
</script>
<div class="result"></div>
JSON https://jsfiddle.net/pcgn73zf/
Would love your help!