I am trying to fetch data from the database but I can't. I can't understand how to fetch data from an array of objects.
[
{
"id": 2,
"folderName": "pop",
"folderImage": "68d04dac-6947-4c3f-906b-c97b2777cbc2slide07.jpg",
"slug": "pop-6g4",
"folderStatus": "open",
"mediaType": "audio",
"createdAt": "2021-10-11T11:13:09.000Z",
"updatedAt": "2021-10-11T11:13:09.000Z",
"userId": 98,
"audios": [
{
"aTitle": "Roi Na Je yaad Meri Aayi Ve New Number",
"aImage": "59622f15-3b54-4d53-8ad0-5533ee4c248fslide10.jpg",
"votes": [
{
"vottingNum": 5,
"totalVote": 5,
"voteCount": 1,
"failSafe": 0
},
{
"vottingNum": 0,
"totalVote": 0,
"voteCount": 1,
"failSafe": 50
}
]
}
]
}
]
folderName easily fetched but can't fetch the audios [] data and votes[] data
I am using sequelize and node js.my controller looks like that
const folderId = req.params.id;
try {
const folderWiseReport = await AudioFolder.findAll({
where: {
id: folderId,
},
include: [
{
model: Audio,
attributes: ['aTitle', 'aImage'],
include: [
{
model: Vote,
attributes: [
'vottingNum',
'totalVote',
'voteCount',
'failSafe',
],
},
],
},
],
// raw: true,
nest: true,
});
return res.json(folderWiseReport);
} catch (error) {
console.log(error);
}
and in the frontend look like
{{#each folderWiseReport}}
<td>{{this.audios.aTitle}}</td>
<td>{{this.audios.votes.vottingNum}}</td>
{{/each}}
I need some information on how to achieve this.