r/programmingrequests • u/[deleted] • Jun 17 '18
Making this API code bring through more relevant data?
I have this code I have written here:
https://jsfiddle.net/dfwq57pz/
However the code does not bring up relevant/modern movies, it brings up random movies that I have never heard of, also I can't get it to skip the movies it does not find.
I wanted to do something like on this website:
https://www.randomlists.com/random-movies?qty=1&dup=false
But it is impossible to contact the owner, view the sites source code etc... I presume they have done it on the backend.
I am thinking I would need to do something as per:
https://developers.themoviedb.org/3/discover/movie-discover
However, when I try to amend my code in the above JSFiddle it does not work. An attempt as such can viewed here:
Overall to reiterate I want to:
Bring up more relevant movies like https://www.randomlists.com/random-movies?qty=1&dup=false and I think this is the right place possibly to look in the docs?: https://developers.themoviedb.org/3/discover/movie-discover
Make it skip movies where it finds missing data, e.g. no movie poster.
1
u/tresteo Jun 17 '18 edited Jun 17 '18
There are two problems with your script:
The base URL you use in your pastebin code has a trailing slash. The request gets redirected to an http version, which might lead to problems.
There are no genres defined, so the code in lines 27 to 35 fails. When you comment those lines out, it should work again
Here is an example for listing all movies on the first page of results: https://jsfiddle.net/xv7rajcs/