GithubHelp home page GithubHelp logo

u1_lab_tmdb_api's Introduction

TMDB API

movie

Overview

In this exercise you will retrieve movie data from the TMDB API and render it in the browser.

TMDB

First, head over to the TMDB website and sign up for your own API key (free option is perfectly fine). Next, check out the documentation Here. Here you will find instructions on how to structure your endpoint for your axios calls. You can also find different parameters to use and what they are for. Remember, every API is different so you will need to read into what works for this API.

Starter Code

If you look at the files we've given you, you will find some basic HTML and CSS to get you started. In the JavaScript file, we've set up a base URL for your endpoint. All you need to do is plug in your API key and add your parameter to the end.

Getting Started

  • fork and clone this repo.
  • cd into it and open it with code .

Requirements

  • A text input + button for searching TMDB by movie title (provided in the starter code).
  • Display a list of movies returned by the search API call. At least the movie's title and poster should be visible.
  • Incorporate CSS flexbox (and maybe grid?) into your page to better display your results.

Steps

Here is a suggested guide for getting through the lab:

  • Attach an event listener that simply logs the text value of the input
  • Once you can see the value being outputted, store this in a variable outside of your event listener.
  • Next, add the axios API call. For searching, the URL should look something like this: https://api.themoviedb.org/3/search/movie?query=[your search query]&api_key=[yourkey]
  • Remember to use async and await for the axios calls
  • Try to console.log the search results.

For this first bit, you should be able to verify in the console that you are successfully retrieving information from TMDB.

  • Next, write a method called renderList that receives an array of "movie" objects as a parameter. Call renderList from the event handler you wrote in the previous step and pass it the Search results from the axios response.
  • renderList should iterate over the movies it receives as an argument and insert the movie data from each object into the DOM as a new HTML element.

Before moving on, try to verify that you can enter text into the text input, click the button, and then see a list of movies appear on the page.

Bonus !!!

If you need an extra challenge and practice, let's get ready to add a viewDetails button to each movie. We will need an event listener either on the movie's poster or a button near the movie's title that will allow a user to "select" or "view more info" about the movie. The listener should make a second API call to retrieve information about the movie. If a movie is "selected", display the movie's data at the top of the page.

  • Go back to the movie list. Add a button to each movie in the list.
  • When a user clicks on this button, pass the movie's id or title to the TMDB API to retrieve more information about the movie. Try to console log or display the URL for each button and test it in the browser's navigation bar if you're having issues with this step.
  • Using the data returned from the API, display the movie's additional info at the top of the page.

More Bonus !

  • Change up the style for the page. Make it your own!

Resources

u1_lab_tmdb_api's People

Contributors

anpato avatar nobodyslackey avatar ahonore42 avatar laurenegrubb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.