Tuesday 21 February 2017

How to pass array to .ejs file then iterate through it.

I pass an object when i call res.render('index',{books: bookArray});on the client side I try to do this:
    <% books.forEach(function(book){ %>
  • <%- book.id %>
  • <%});%>
I get this error: Cannot read property 'forEach' of undefined

Submitted February 22, 2017 at 01:58AM by farhansyed7911

No comments:

Post a Comment