Myriad Systems.
To solve this challenge, write an HTTP GET method to retrieve information from a particular movie database.
https://stackoverflow.com/questions/48448432/fragment-of-missing-code-in-the-solution-movie-titles-complete-a-challenge-more
function getMovieTitlesData(title, page = 1) { const url = 'https://jsonmock.hackerrank.com/api/movies/search/?Title=' + title + '&page=' + page; console.log('URL:',url); const titles = []; return new Promise((resolve, reject) => { fetch(url, { method: 'get', }).then((response) => { return response.json(); }).then((jsondata) => { for (let i = 0; i < jsondata.data.length; i++) { titles.push(jsondata.data[i].Title); } var total_pages = Number(jsondata.total_pages); var curpage = Number(jsondata.page); resolve({ titles : titles, page : page, total_pages : total_pages }); }).catch((error) => { console.log("Failure", error); }) }) } function getMovieTitles(substr) { const promises = []; const titles = []; getMovieTitlesData(substr).then(result => { titles.push(...result.titles); for (let i = result.page + 1; i <=result.total_pages; i++) { promises.push(getMovieTitlesData(substr, i)); } Promise.all(promises).then(datas => { datas.forEach(data => { titles.push(...data.titles); }); console.log(titles.sort()); }); }) } getMovieTitles('spiderman');