Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js forEach不是一个路由中的函数,而是另一个路由中的函数_Node.js_Mongodb_Foreach_Httprequest_Ejs - Fatal编程技术网

Node.js forEach不是一个路由中的函数,而是另一个路由中的函数

Node.js forEach不是一个路由中的函数,而是另一个路由中的函数,node.js,mongodb,foreach,httprequest,ejs,Node.js,Mongodb,Foreach,Httprequest,Ejs,我知道forEach需要数组数据类型才能工作。但是,我的数据是客户列表(在Mongodb集合中),它被传递到“/view customers”路径中的另一个forEach循环中,并且可以正常工作。但我无法让它在另一条路径(“/transaction”)中工作 //数据库项“: my transaction.ejs代码: <%- include("partials/header"); -%> <h3>Transaction Porta

我知道forEach需要数组数据类型才能工作。但是,我的数据是客户列表(在Mongodb集合中),它被传递到“/view customers”路径中的另一个forEach循环中,并且可以正常工作。但我无法让它在另一条路径(“/transaction”)中工作

//数据库项“:

my transaction.ejs代码:

<%- include("partials/header"); -%> 


       <h3>Transaction Portal:</h3>
<br><br><br>
<h4>Welcome, please select the sender and the amount you want to transfer to <span class="color"><%= customerName %></span></h4><br><br>
<form action="/transaction/<%= customerName %>" method="post">

    <h4>Sender:</h4>
   <select>
    <option>
                       <ol>
  <% customers.forEach(function(customer){ %>
                     <br> <%= customer.name %>
  <% }); %>
</ol>
       </option> 
    </select>
    <input type="number" id="amount" name="amount" placeholder="Enter transfer amount"><button id="transfer" type="submit" value="Transfer">Transfer</button>

</form>

<%- include("partials/footer"); -%>

交易门户:



欢迎光临,请选择发件人和您要转账的金额

发件人:
转移
我非常抱歉,因为我的问题太长太无聊,无法通过!但如果您能抽出时间回答我的问题,我将不胜感激。
此外,这是我的第一个问题,如果我在构建/解释它时犯了任何错误,我向您道歉。

'customers':[customer\u list]
替换为
customers:customer\u list
//([{ "name" : "Shruti Sinha", "currentbalance" : 1000 },
//{  "name" : "Aryan Singh", "currentbalance" : 6000 },
//{ "name" : "James Brown", "currentbalance" : 9000 },
//{ "name" : "Nupur Sen", "currentbalance" : 12000 },
//{  "name" : "Oishiki Ganguly", "currentbalance" : 15000 },
//{  "name" : "Aditi Patel", "currentbalance" : 11000 },
//{  "name" : "Rohan Bharadwaj", "currentbalance" : 10000 },
//{  "name" : "Samarth Shah", "currentbalance" : 1000 },
//{  "name" : "Ananya Maheshwari", "currentbalance" : 8000 },
//{"name" : "Ayush Kalra", "currentbalance" : 20000 }])
<%- include("partials/header"); -%> 


       <h3>Transaction Portal:</h3>
<br><br><br>
<h4>Welcome, please select the sender and the amount you want to transfer to <span class="color"><%= customerName %></span></h4><br><br>
<form action="/transaction/<%= customerName %>" method="post">

    <h4>Sender:</h4>
   <select>
    <option>
                       <ol>
  <% customers.forEach(function(customer){ %>
                     <br> <%= customer.name %>
  <% }); %>
</ol>
       </option> 
    </select>
    <input type="number" id="amount" name="amount" placeholder="Enter transfer amount"><button id="transfer" type="submit" value="Transfer">Transfer</button>

</form>

<%- include("partials/footer"); -%>