File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
CRUD API's/app/controllers Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments