I'm building an IMDB-like app for a college assignment in react native, and i'm having trouble with the multi search function.
when i have my endpoint search for movies, everything works just fine, but if i change the endpoint to search tv shows or multiple search, it returns empty for some reason.
would be glad if anyone might help.
Nevari atrast filmu vai TV pārraidi? Jāpiesakās, lai to izveidotu.
Vēlies novērtēt šo vienumu vai pievienot to sarakstam?
Neesi dalībnieks?
Atbilde no robbie3999
on jūlijs 17, 2023 at 1:35 PM
Hi @Gunlol, to get assistance, please supply the api urls you are using. Replace your api key with a string like API_KEY or xxxxxxx.
Atbilde no Gunlol
on jūlijs 17, 2023 at 1:59 PM
as it says, this is the base URL
this is the URL end point i'm using. if i replace the movie with tv or multi (as in the documentation), i get an empty array as the result.
this is the apiCall function i'm using
this is the function for the search im using, that passes the parameters to the apiCall function above
Atbilde no robbie3999
on jūlijs 17, 2023 at 4:42 PM
Hi @Gunlol, all of these methods require a query string. For example:
That's why they aren't returning anything. Here is the doc:
https://developer.themoviedb.org/reference/search-movie
https://developer.themoviedb.org/reference/search-tv
https://developer.themoviedb.org/reference/search-multi
Atbilde no Gunlol
on jūlijs 18, 2023 at 5:45 AM
small update, i managed to find out that i am getting a result back from the api call, but for some reason its not storing the result.
im using .map to go over the array that comes back from the api call, but i either have a problem with the .map function or the .length function.
im using react native expo, and the error im having is "cannot read property 'length' of undefined".
everything works fine when i have the endpoint set as: search/movie, but it doesn't work when i have it set as: search/tv or search/multi
Atbilde no Gunlol
on jūlijs 19, 2023 at 7:46 AM
Hi @robbie3999,would be glad if you could help me.
Atbilde no robbie3999
on jūlijs 19, 2023 at 10:01 AM
hi @Gunlol, I would be glad to help but I don't do javascript coding. I can provide you help with the tmdb api calls as needed.
A quick search of "cannot read property 'length' of undefined" for react/javascript shows this, it looks like you are trying to use the length property on something that is undefined or empty so check the value first before trying to use length.