0

I've been trying to connect my bootstrap card deck to a mongo database using ejs. No errors, but the cards aren't appearing when I render the website. Does anyone know what might be wrong?

Here's the code:

<div class="container">
<div class="row row-cols-4">
<% researchCards.forEach(function(researchCard){ %>
      <div class="card col">
        <div class="card-body">
          <h5 class="card-title"><%= researchCard.title %></h5>
          <h6 class="card-title"><%= researchCard.credit %></h6>
          <p class="card-text"><%= researchCard.content %></p>
          <a href="<%= researchCard.link %>">Read more</a>
        </div>
    </div>
</div>
<% }); %>

The mongodb model is called "ResearchCards", I have added two to the database, but they don't turn up on the page and I can't work out why. I'm not a very experienced programmer, so any advice (in simple terms) would be very appreciated!

Rowan
  • 9
  • 2

1 Answers1

0

Try below code:

<div class="container">
  <div class="row row-cols-4">
    <% researchCards.forEach(function(researchCard){ %>
      <div class="card col">
        <div class="card-body">
          <h5 class="card-title"><%= researchCard.title %></h5>
          <h6 class="card-title"><%= researchCard.credit %></h6>
          <p class="card-text"><%= researchCard.content %></p>
          <a href="<%= researchCard.link %>">Read more</a>
        </div>
      </div>
    <% }); %>
  </div>
</div>
Rashed Rahat
  • 2,357
  • 2
  • 18
  • 38