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:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user