Project 3: Movie Finder

I think there is a mistake in my js code but I cannot find it.
I am attaching my js code here.

@santanusingh018 Append &t= in API_URL and &i= in API_URL_SEARCH.

const API_URL="[yourkey]&t="
const API_URL_SEARCH = "[yourkey]&i="

I had made the changes but still I cannot get the search result on chrome.

Hi @santanusingh018,

In the above lines, have you replaced [yourkey] with your API key?

Also since you have shared your API key on the forum, please re-generate it.

@raghav.srivastava yes, I had made the changes that you suggested but I am not getting the desired results.
In the console, it shows something like this:
‘Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘forEach’)
at showMovies (movie_finder.js:24:9)
at getMovies (movie_finder.js:19:2)’.

Hi @santanusingh018 ,
Kindly use Array.from() to convert the HTML collection into array. Please see the code below

//make the changes on line #24
Array.from(movies).forEach(async ........

@raghav.srivastava I had made the changes but it is still showing some error.
Console shows:
“Uncaught (in promise) TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.from ()
at showMovies (movie_finder.js:24:8)
at getMovies (movie_finder.js:19:2)”

Hi @santanusingh018 ,
Can you please share the code?

My html code:

My js code:

Hi @santanusingh018 ,
Make the following changes,
Change &t= to &s=

const API_URL="[yourkey]&s="

Also,you may remove Arrays.from()

It should work

1 Like

@raghav.srivastava yes now after changing the api, I am getting the results. Thank you for your help.

1 Like