Changed a smellingerror (reponse -> response). Also now pass the type of the search request when converting to seasoned object. Fixed issue where number_of_items_on_page was not set to the length of the list.

This commit is contained in:
2017-09-27 00:22:22 +02:00
parent 6bd1b29d5e
commit d787fba024

View File

@@ -22,20 +22,20 @@ class TMDB {
return Promise.resolve()
.then(() => this.tmdb(type, query)) // Search the tmdb api
.catch(() => { throw new Error('Could not search for movies.'); }) // If any error at all when fetching
.then((reponse) => {
.then((response) => {
try {
// We want to filter because there are movies really low rated that are not interesting to us.
let filteredTmdbItems = reponse.results.filter(function(tmdbResultItem) {
let filteredTmdbItems = response.results.filter(function(tmdbResultItem) {
return ((tmdbResultItem.vote_count >= 80 || tmdbResultItem.popularity > 18) && (tmdbResultItem.release_date !== undefined || tmdbResultItem.first_air_date !== undefined))
})
// Here we convert the filtered result from the tmdb api to seaonsed objects
let seasonedItems = filteredTmdbItems.map((tmdbItem) => {
return convertTmdbToSeasoned(tmdbItem);
return convertTmdbToSeasoned(tmdbItem, type);
});
// TODO add page number if results are larger than 20
return { 'results': seasonedItems, 'number_of_items_on_page': seasonedItems,
return { 'results': seasonedItems, 'number_of_items_on_page': seasonedItems.length,
'page': 1, 'total_pages': 1 };
} catch (parseError) {