Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a couple small things to make the app work #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ module.exports = mongoose.model('Todo', {
text: {
type: String,
default: ''
},
done: {
type: Boolean,
default: false
}
});
});
22 changes: 12 additions & 10 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ function getTodos(res) {

// if there is an error retrieving, send the error. nothing after res.send(err) will execute
if (err) {
console.error('err :',err);
res.send(err);
}

res.json(todos); // return all todos in JSON format
} else
res.json(todos); // return all todos in JSON format
});
};

Expand All @@ -29,11 +29,12 @@ module.exports = function (app) {
text: req.body.text,
done: false
}, function (err, todo) {
if (err)
if (err) {
console.error('err :',err);
res.send(err);

// get and return all the todos after you create another
getTodos(res);
} else
// get and return all the todos after you create another
getTodos(res);
});

});
Expand All @@ -43,10 +44,11 @@ module.exports = function (app) {
Todo.remove({
_id: req.params.todo_id
}, function (err, todo) {
if (err)
if (err) {
console.error('err :',err);
res.send(err);

getTodos(res);
} else
getTodos(res);
});
});

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"author": "Scotch",
"dependencies": {
"body-parser": "^1.18.2",
"mongoose": "4.10.8",
"express": "^4.10.8",
"mongoose": "6.10.0",
"express": "^4.17.3",
"method-override": "^2.3.10",
"morgan": "^1.9.0"
}
Expand Down