[英]Why do I get an Unexpected end of JSON input at JSON.parse error
When I run the following ejs code using npm start
, it displays syntax error.当我使用npm start
运行以下 ejs 代码时,它显示语法错误。
Here is the code.这是代码。 I think in my guess, the error is related to the arrow(=>).我认为在我的猜测中,错误与箭头(=>)有关。
<% JSON.parse(documents).forEach(document => { %>
<a class="list-group-item list-group-item-action" id="<%= document.Key %>" data-bs-toggle="tab"
href="#list-<%= document.Key %>" role="tab" aria-controls="list-<%= document.Key %>" style="min-width: 200px;"><%= document.Key %></a>
<% }) %>
Here is the exact error displayed when I run localhost:3000/ on the browser这是我在浏览器上运行 localhost:3000/ 时显示的确切错误
SyntaxError: /javascript/views/pages/dashboard.ejs:14
12| <div class="list-group" id="list-tab" role="tablist" style="margin-top: 10px;">
13|
>> 14| <% JSON.parse(documents).forEach(document => { %>
15| <a class="list-group-item list-group-item-action" id="<%= document.Key %>" data-bs-toggle="tab"
16| href="#list-<%= document.Key %>" role="tab" aria-controls="list-<%= document.Key %>" style="min-width: 200px;"><%= document.Key %></a>
17| <% }) %>
Unexpected end of JSON input at JSON.parse (<anonymous>)
Replace JSON.parse(documents).forEach(document..
into documents.forEach(document
将JSON.parse(documents).forEach(document..
替换为documents.forEach(document
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.