Using Nodejs and ejs on the front end I have sent across an array, which has arrays inside it. However when I loop through and step into the array I'm outputted with the first item in each array rather than all the items in the array of arrays. My question is how to display all these posts? A console log shows all the posts are present just a question of how to extract them.
Below is my dummy data array and below that is a sample of the front end, any help would be grateful.
[
[
{
post_created_by: 'supervalue',
post_created_by_id: 54ecb20852ea734c0598c47b,
title: 'salmon',
desc: '3 for 2 fresh sea salmon',
_id: 5501b88c68e8b5842ece6eb0
},
{
post_created_by: 'supervalue',
post_created_by_id: 54ecb20852ea734c0598c47b,
title: 'Milkshake',
desc: 'Avonmore fresh strawberry milkshake 6 pack',
_id: 5501b8fd68e8b5842ece6eb1
}
],
[
{
post_created_by: 'maxol',
post_created_by_id: 54ecb2cd52ea734c0598c47e,
title: 'petrol',
_id: 5501bb9168e8b5842ece6eb6
},
{
post_created_by: 'maxol',
post_created_by_id: 54ecb2cd52ea734c0598c47e,
title: 'tayto',
desc: '20 packs for the price of 12',
_id: 5501bbb168e8b5842ece6eb7
}
],
[
{
post_created_by: 'Burkes Shoes',
post_created_by_id: 5502033d3d108e141dd01e8c,
title: 'boots',
desc: 'soccer boots size 5',
_id: 5502036a3d108e141dd01e8d
}
]
]
<% for (var i = 0; i < posts.length; i++) { %>
<div class="col-xs-8">
<a href="/busProfileFromUser?busId=<%= posts[i][0].post_created_by_id %>">
<h5><%= posts[i][0].post_created_by %></h5>
</a>
</div>