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()
|
||||
.then(() => tmdb.search(query, page, type))
|
||||
.then((movies) => {
|
||||
if (movies.length > 0) {
|
||||
if (movies !== undefined || movies.length > 0) {
|
||||
res.send(movies);
|
||||
} else {
|
||||
res.status(404).send({ success: false, error: 'Search query did not return any results.'})
|
||||
|
||||
Reference in New Issue
Block a user