Small changed that first checks if the variable is undefined or not and then length
This commit is contained in:
@@ -14,7 +14,7 @@ function searchMoviesController(req, res) {
|
|||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => tmdb.search(query, page, type))
|
.then(() => tmdb.search(query, page, type))
|
||||||
.then((movies) => {
|
.then((movies) => {
|
||||||
if (movies.length > 0) {
|
if (movies !== undefined || movies.length > 0) {
|
||||||
res.send(movies);
|
res.send(movies);
|
||||||
} else {
|
} else {
|
||||||
res.status(404).send({ success: false, error: 'Search query did not return any results.'})
|
res.status(404).send({ success: false, error: 'Search query did not return any results.'})
|
||||||
|
|||||||
Reference in New Issue
Block a user