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:
		@@ -22,20 +22,20 @@ class TMDB {
 | 
				
			|||||||
		return Promise.resolve()
 | 
							return Promise.resolve()
 | 
				
			||||||
		 .then(() => this.tmdb(type, query))  // Search the tmdb api
 | 
							 .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
 | 
							 .catch(() => { throw new Error('Could not search for movies.'); })  // If any error at all when fetching
 | 
				
			||||||
		 .then((reponse) => {
 | 
							 .then((response) => {
 | 
				
			||||||
		 	try {
 | 
							 	try {
 | 
				
			||||||
		 		// We want to filter because there are movies really low rated that are not interesting to us. 
 | 
							 		// 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))
 | 
							 			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
 | 
							 		// Here we convert the filtered result from the tmdb api to seaonsed objects
 | 
				
			||||||
		 		let seasonedItems = filteredTmdbItems.map((tmdbItem) => {
 | 
							 		let seasonedItems = filteredTmdbItems.map((tmdbItem) => {
 | 
				
			||||||
		 			return convertTmdbToSeasoned(tmdbItem);
 | 
							 			return convertTmdbToSeasoned(tmdbItem, type);
 | 
				
			||||||
		 		});
 | 
							 		});
 | 
				
			||||||
		 		
 | 
							 		
 | 
				
			||||||
		 		// TODO add page number if results are larger than 20
 | 
							 		// 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 };
 | 
											'page': 1, 'total_pages': 1 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		 	} catch (parseError) {
 | 
							 	} catch (parseError) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user