0
所以我試圖建立一個基本的Todo列表/ CRUD應用程序使用MEAN堆棧(Angular,MongoDB,Nodejs,Express),當我切換時遇到麻煩路徑和模型,並嘗試在我的命令提示符下通過節點服務器加載應用程序。當我移動任何東西時,下面的錯誤是通過命令提示符錯誤得到的。只是一個參考,我是一個總NOOB。404錯誤嘗試加載平均網絡應用程序
App listening on port 3000
GET /api/todos 404 2ms
GET /api/todos 500 7ms - 1.36kb
ReferenceError: Todo is not defined
at app.delete.Todo.remove._id (C:\Users\Basel\WebstormProjects\TEST\node-tod
o-tut1-starter\server.js:41:3)
at callbacks (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starter\no
de_modules\express\lib\router\index.js:164:37)
at param (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starter\node_m
odules\express\lib\router\index.js:138:11)
at pass (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starter\node_mo
dules\express\lib\router\index.js:145:5)
at Router._dispatch (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-sta
rter\node_modules\express\lib\router\index.js:173:5)
at Object.router (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starte
r\node_modules\express\lib\router\index.js:33:10)
at next (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starter\node_mo
dules\express\node_modules\connect\lib\proto.js:193:15)
at Object.methodOverride [as handle] (C:\Users\Basel\WebstormProjects\TEST\n
ode-todo-tut1-starter\node_modules\express\node_modules\connect\lib\middleware\m
ethodOverride.js:48:5)
at next (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starter\node_mo
dules\express\node_modules\connect\lib\proto.js:193:15)
at multipart (C:\Users\Basel\WebstormProjects\TEST\node-todo-tut1-starter\no
de_modules\express\node_modules\connect\lib\middleware\multipart.js:86:27)
app.post('/api/todos', function(req, res) {
// create a todo, information comes from AJAX request from Angular
Todo.create({
text : req.body.text,
done : false
}, function(err, todo) {
if (err)
res.send(err);
// get and return all the todos after you create another
Todo.find(function(err, todos) {
if (err)
res.send(err)
res.json(todos);
});
});
});
// delete a todo
app.delete('/api/todos/:todo_id', function(req, res) {
Todo.remove({
_id : req.params.todo_id
}, function(err, todo) {
if (err)
res.send(err);
// get and return all the todos after you create another
Todo.find(function(err, todos) {
if (err)
res.send(err)
res.json(todos);
});
});
});
// application -------------------------------------------------------------
app.get('*', function(req, res) {
res.sendfile('./public/index.html'); // load the single view file (angular will handle the page changes on the front-end)
});
使用貓鼬!我會試試這個。 – user2993058
它必須支持BSON對象 –