This is the exact error message I'm getting:
TypeError: /Users/benjidurden/Desktop/page-plant-bonham-jones/views/index.ejs:24
22| <div class="spacing"></div>
23| <div class="content">
24| <%- include ./partials/loops %>
25| </div>
26| <%- include ./partials/scripts %>
27| </body>
esc is not a function at rethrow
(/Users/benjidurden/Desktop/page-plant-bonham-jones/node_modules/ejs/lib/ejs.js:285:18)
Below shows the content of the loops.ejs; the following loop exists inside. Essentially, I was trying to generate a forEach loop that places all of the content inside of this div. Regardless, I don't know how to fix this mistake. Any advice?
<ul>
<% data.forEach(function(d) { %>
<li data-id=<%=d.id%>>
<input class="input_item" type="text" name="first"
placeholder=<%= d.album %> readonly>
<span class="edit">edit</span>
<span class="delete">delete</span>
</li>
<% }) %>
</ul>
This usually triggers when an object is undefined within an ejs template, which might be the reason in your case.
Try logging data
in console. If data
is undefined
then esc is not a function
error is obvious to occur as that means data
is not available to your template and that is what you are trying to display. Resolve this issue by supplying proper data to the template.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.