Advertisement
GATE-MST

jquery function to call TMDB api

Jun 29th, 2023
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.79 KB | Source Code | 0 0
  1.             // function to load popular movies from TMDB on document ready
  2.             var api_key = "ce283f8ff68c019530c5f5ccf045de2d"; //TODO insert your unique API KEY here
  3.             var api_url = "https://api.themoviedb.org/3/movie/popular?api_key=" + api_key;
  4.             $.getJSON(api_url, function (data) {
  5.                 $.each(data.results, function (i, item) {
  6.                     console.log(item)
  7.                     var posterFullUrl = "https://image.tmdb.org/t/p/w185//" + item.poster_path;
  8.                     var img = "<img src='" + posterFullUrl + "' title='" + item.title + " (" + item.release_date.substring(0, 4) + ")'/>";
  9.                     $("#movielist").append(img);
  10.                     $("#movielist_title").text("Popular Movies");
  11.                 });
  12.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement