I have an array of objects being pulled from Mongo, which looks like this:
[
{
_id: 5f2038de019c99595df20977,
fromDoctor: 'Dummyname1',
Message: 'dummymessage1'
},
{
_id: 5f2038e5019c99595df20978,
fromDoctor: 'Dummyname2',
Message: 'dummymessage2'
}
]
I'd like to insert this array, which i call allMessages, into an EJS file, displaying them all, something like this:
<div class="NoticeMessage">
<p>Posted by ${notice.fromDoctor}</p>
</br>
<p>Message</p>
</br>
<p>${notice.Message}</p>
</div>
;
I'm attempting to pass the array to ejs when /board (the route) is called, like this:
res.render('Board', {Messages : allMessages});
(I have confirmed that the array is defining properly, allMessages is equal to above array)
I'd like to insert the array and run .forEach with above template code on it, creating a new NoticeMessage for each object in the array, and inserting them into this:
<div class="row mt-5">
<div class="card card-body">
<h2>Message board</h2>
</br>
</br>
<!--INSERT HERE-->
</div>
</div>
But i really don't know how to go about it. Can anyone help me out?