Reputation: 569
SyntaxError: Unexpected token ')' in C:\Users\hp\short.nner\views\index.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
at new AsyncFunction (<anonymous>)
at Template.compile (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:661:12)
at Object.compile (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:396:16)
at handleCache (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:233:18)
at tryHandleCache (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:272:16)
at View.exports.renderFile [as engine] (C:\Users\hp\short.nner\node_modules\ejs\lib\ejs.js:489:10)
at View.render (C:\Users\hp\short.nner\node_modules\express\lib\view.js:135:8)
at tryRender (C:\Users\hp\short.nner\node_modules\express\lib\application.js:640:10)
at Function.render (C:\Users\hp\short.nner\node_modules\express\lib\application.js:592:3)
at ServerResponse.render (C:\Users\hp\short.nner\node_modules\express\lib\response.js:1012:7)
at C:\Users\hp\short.nner\server.js:49:17
at processTicksAndRejections (node:internal/process/task_queues:93:5)
Here's my code:
<%=Url.forEach(shortUrl => { %>
<tr>
<td>
<a href="<%= shortUrl.full %>">
<%= shortUrl.full %>
</a>
</td>
<td>
<a href="<%= shortUrl.short %>">localhost:3000/<%= shortUrl.short %></a
>
</td>
<td><%= shortUrl.clicks %></td>
<td><%= shortUrl.GivenEmail %>
</tr>
<% }) %>
I really don't know why I am getting this error please help. I did give the Url as an option to my ejs but I get this strange error on running it.
Upvotes: 0
Views: 1790
Reputation: 7114
I wasn't able to fully test your code yesterday because I was on mobile.
The problem is actually coming from the =
in the beginning of <%=Url.forEach(shortUrl =>
. Just remove it like this should work:
<% Url.forEach(shortUrl => { %>
<tr>
<td>
<a href="<%= shortUrl.full %>">
<%= shortUrl.full %>
</a>
</td>
<td>
<a href="<%= shortUrl.short %>">localhost:3000/<%= shortUrl.short %></a
>
</td>
<td><%= shortUrl.clicks %></td>
<td><%= shortUrl.GivenEmail %>
</tr>
<% }) %>
That should dismiss the error.
Upvotes: 1