Skip to content

Commit 90dead0

Browse files
committed
final touch CRUD API's
1 parent c4dbc3c commit 90dead0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CRUD API's/app/controllers/controller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ exports.findone=function(req,res){
4343

4444
Note.findById(req.params.noteId,function(err,doc){
4545
if(err) return res.status(400).send(err);
46-
47-
res.status(200),json(doc);
46+
if(!doc) return res.status(404).json({message : "Note with given Id is not found"});
47+
res.status(200).json(doc);
4848
})
4949

5050

@@ -55,7 +55,7 @@ exports.findbyauthor=function(req,res){
5555
Note.find({author:req.params.author},function(err,note){
5656
if(err) return res.status(400).send(err);
5757

58-
if(!note) return res.status(404).send({message:"not found"});
58+
if(!note) return res.status(404).json({message:"not found"});
5959

6060
res.status(200).json(note);
6161

@@ -67,7 +67,7 @@ exports.findbytitle=function(req,res){
6767
Note.find({title:req.params.title},function(err,note){
6868
if(err) return res.status(400).send(err);
6969

70-
if(!note) return res.status(404).send({message:"not found"});
70+
if(!note) return res.status(404).json({message:"not found"});
7171

7272
res.status(200).json(note);
7373
});

0 commit comments

Comments
 (0)