Changed variable name from movie to searchResult and now checks if the result list in the return JSON object is empty before sending a result back to client.

This commit is contained in:
2017-09-20 10:25:01 +02:00
parent 2d465d841e
commit ae66e9a684

View File

@@ -6,10 +6,10 @@ function searchRequestController(req, res) {
console.log('searchReq: ' + query, page, type); console.log('searchReq: ' + query, page, type);
requestRepository.searchRequest(query, page, type) requestRepository.searchRequest(query, page, type)
.then((movies) => { .then((searchResult) => {
// Verify that respond has content, if so send the content back // Verify that respond has content, if so send the content back
if (movies.length > 0 && movies != null) { if (searchResult.results.length > 0) {
res.send(movies); res.send(searchResult);
} }
// If no content was found, send 404 status and error message // If no content was found, send 404 status and error message
else { else {