@@ -20,17 +20,17 @@ v1.get("/", (req, res) => {
2020 if ( year ) {
2121 global . db . collection ( "launch" ) . find ( { "launch_year" : `${ year } ` } , { "_id" : 0 } ) . sort ( { "flight_number" : - 1 } )
2222 . toArray ( ( err , doc ) => {
23- if ( doc [ 0 ] === undefined ) {
24- res . end ( "No results found " )
23+ if ( doc . length == 0 ) {
24+ res . end ( "No Matches Found " )
2525 }
2626 res . end ( JSON . stringify ( doc , null , 2 ) )
2727 } )
2828 } else if ( start && final ) {
2929 global . db . collection ( "launch" ) . find ( { "launch_date_utc" : { "$gte" : `${ start } T00:00:00Z` , "$lte" : `${ final } T00:00:00Z` } } , { "_id" : 0 } )
3030 . sort ( { "flight_number" : 1 } )
3131 . toArray ( ( err , doc ) => {
32- if ( doc [ 0 ] === undefined ) {
33- res . end ( "No results found " )
32+ if ( doc . length == 0 ) {
33+ res . end ( "No Matches Found " )
3434 }
3535 res . end ( JSON . stringify ( doc , null , 2 ) )
3636 } )
@@ -49,8 +49,8 @@ v1.get("/cores/:core", (req, res) => {
4949 global . db . collection ( "launch" ) . find ( { "core_serial" : `${ core } ` } , { "_id" : 0 } ) . sort ( { "core_serial" : 1 } )
5050 . toArray ( ( err , doc ) => {
5151 if ( err ) return console . log ( err )
52- if ( doc [ 0 ] === undefined ) {
53- res . end ( "No results found " )
52+ if ( doc . length == 0 ) {
53+ res . end ( "No Matches Found " )
5454 }
5555 res . end ( JSON . stringify ( doc , null , 2 ) )
5656 } )
@@ -62,8 +62,8 @@ v1.get("/caps/:cap", (req, res) => {
6262 global . db . collection ( "launch" ) . find ( { "cap_serial" : `${ cap } ` } , { "_id" : 0 } ) . sort ( { "capsule_serial" : 1 } )
6363 . toArray ( ( err , doc ) => {
6464 if ( err ) return console . log ( err )
65- if ( doc [ 0 ] === undefined ) {
66- res . end ( "No results found " )
65+ if ( doc . length == 0 ) {
66+ res . end ( "No Matches Found " )
6767 }
6868 res . end ( JSON . stringify ( doc , null , 2 ) )
6969 } )
0 commit comments