我正在创建一个node.js应用程序并实现调度程序应用程序。我将遵循这个演练:https://dhtmlx.com/blog/using-dhtmlxscheduler-with-node-js/
当我导航到/data页面时,它显示不能读取未定义的属性'length‘。我访问了github页面并下载了app.js word。
下面是抛出app.js部分的错误:
app.get('/data', function(req, res){
db.event.find().toArray(function(err, data){
//set id property for all records
for (var i = 0; i < data.length; i++)
data[i].id = data[i]._id;
//output response
res.send(data);
});
});发布于 2019-02-03 08:08:51
这个example运行良好。我猜,在您的例子中,由于某些原因,mongoskin无法连接到mongodb。如果我更改此路径mongodb://localhost/testdb中的某些部分(出于测试目的,放置一些随机字符串),mongodb将报告url有问题,并且我将从节点js获得错误TypeError: Cannot read property 'length' of undefined,因为将不会从数据库中提取数据。
https://stackoverflow.com/questions/54497237
复制相似问题