Small changed that first checks if the variable is undefined or not and then length

This commit is contained in:
2017-09-03 17:06:19 +02:00
parent e81f5c8057
commit 7a1f709d90

View File

@@ -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.'})