From 2827cd79b9180ea4616258f7090f83945b267115 Mon Sep 17 00:00:00 2001 From: Rajat Sharma <33171120+rajats98@users.noreply.github.com> Date: Wed, 15 Jan 2020 19:12:00 +0530 Subject: [PATCH 1/2] Create README.md --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ffd654 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# Complete RESTful Todos API + +## Overview +Todo-list app to manage todos, created using Node,Express,MongoDb. + +**Functionalities** + +1).Add a todo + +2).Mark a todo done + +3).Delete a todo + +## Built with Node, Express, and Mongo +(node,npm and MongoDb should be installed to run this) + +Install dependecies using +``` + npm install +``` +Create/Start Mongo server +and then Start Node server using +``` + node index.js +``` + From 0d752b418d61be46908167931204d36f82e2f945 Mon Sep 17 00:00:00 2001 From: Rajat Sharma <33171120+rajats98@users.noreply.github.com> Date: Thu, 16 Jan 2020 00:24:12 +0530 Subject: [PATCH 2/2] Update todos.js --- helpers/todos.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/todos.js b/helpers/todos.js index 88a7840..114c3cf 100644 --- a/helpers/todos.js +++ b/helpers/todos.js @@ -3,7 +3,7 @@ var db = require('../models'); exports.getTodos = function(req,res) { db.Todo.find() .then(function(todos) { - res.status(201).json(todos); + res.json(todos); }) .catch(function(err) { res.send(err); @@ -13,7 +13,7 @@ exports.getTodos = function(req,res) { exports.createTodo = function(req,res){ db.Todo.create(req.body) .then(function(newTodo) { - res.json(newTodo); + res.status(201).json(newTodo); }) .catch(function(err) { res.send(err); @@ -50,4 +50,4 @@ exports.deleteTodo = function(req,res){ }) } -module.exports = exports; \ No newline at end of file +module.exports = exports;