morecallan / movie-history-api

Zoe is awesome.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Users should be able to search for movies using TMDB

zoeames opened this issue · comments

Story

As a user, when I search for a movie, I should see possible matches.

Acceptance Criteria

When the user types a movie into the search bar
Then the user presses enter
And the code should hit the TMDB api
And the user should see the movies that TMDB returns.

Technical Resource

Use TMDB as your API.

Comment by zoeames
Monday Oct 16, 2017 at 04:02 GMT


We will be making a GET to /search/movie

https://api.themoviedb.org/3/search/movie?api_key=<<api_key>>&language=en-US&page=1&include_adult=false

Comment by zoeames
Monday Oct 16, 2017 at 04:03 GMT


TMDB requires that we send an API key for every request. I have an API key from my account. I need to secure it so i will put it in db/apiKeys.json in an object that looks like:

{
	"apiKeys": {
		"tmdb": {
			"apiKey": "##############"
		}
	}
}

I will then add this file to my .gitignore. To make it clear to users the structure they need for this file, I will create an db/apiKeys.example.json

{
	"apiKeys": {
		"tmdb": {
			"apiKey": ""
		}
	}
}

I will nee to add instructions to my readme to get an API key and rename apiKeys.example.json to apiKeys.json.

Comment by zoeames
Monday Oct 16, 2017 at 04:08 GMT


create javascripts/apiKeys.js

This file will have two functions:

  1. apiKeys - promise for db/apiKeys.json
  2. retrieveKeys - executes apiKeys. on successful load calls tmdb.setKey
module.exports = {retrieveKeys};

Comment by zoeames
Monday Oct 16, 2017 at 04:11 GMT


create javascripts/tmdb.js
This file will have 4 functions:

  1. searchTMDB - promise for search API call (see first comment for route)
  2. searchMovies - executes searchTMDB and passes in the search text from the input field
  3. setKey - accepts a string, this function sets the private variable tmdbKey to the string passed in
  4. showResults - accepts an array, calls dom.domString and passes the array

Comment by zoeames
Monday Oct 16, 2017 at 04:13 GMT


create javascripts/events.js

This file has 1 function

pressEnter - keypress event on document that checks if the enter key was pushed. if it was the enter key this function:

  1. grabs the val() of the searchbar
  2. replaces any spaces with "%20"
  3. calls tmdb.searchMovies and passes the string from 2

Comment by zoeames
Monday Oct 16, 2017 at 04:14 GMT


modify main.js to call the following functions:

apiKeys.retrieveKeys();
events.pressEnter();