public/index.js
// Get movies from server then pass them to the updateMovies method
Get movies from server then pass them to the updateMovies method
Get movies from server then pass them to the updateMovies method
function fetchAndUpdateMovies() {
    let movieTitleElement = document.getElementById("movieTitle");
    let movieTitle = movieTitleElement.value;
    if (!movieTitle) {
        console.log(movieTitle);
        console.log("Invalid movie title.");
        return;
    }
    httpGetAsync("http://www.omdbapi.com/?apikey=" + API_KEY + "&s=" + movieTitle,
        response => {
            let movies = JSON.parse(response).Search;
            if (!movies) {
                alert("Cant find any movies.");
                return;
            }
            updateMovies(movies)
    });
}
function fetchAndUpdateMovies ( ) { let movieTitleElement = document . getElementById ( "movieTitle" ) ; let movieTitle = movieTitleElement . value ; if ( ! movieTitle ) { console . log ( movieTitle ) ; console . log ( "Invalid movie title." ) ; return ; } httpGetAsync ( "http://www.omdbapi.com/?apikey=" + API_KEY + "&s=" + movieTitle , response => { let movies = JSON . parse ( response ) . Search ; if ( ! movies ) { alert ( "Cant find any movies." ) ; return ; } updateMovies ( movies ) } ) ; }
Get movies from server then pass them to the updateMovies method
Get movies from server then pass them to the updateMovies method
// Extract the movie title from the search bar // Make sure the title is valid // Update movies listed with results from api