I'm using an API that allows me to access JSON objects which I've used and convert in to a JavaScript object. I get a console log of film names so this works.
Now I'm I was wondering is it possible to reference this film object in other functions? or do I need to do a request in every function to access the film properties?
$("#search-button").click(function(){
   search();
});
function search() {
  var userInput = $("#content-container-search").val().replace(/\s+/g,"%20");
  var searchTerm = "".concat(standardURL, apiKey, 'query=', userInput);
  var request = new XMLHttpRequest();
  request.open('GET', searchTerm , true);
  request.onload = function(data) {
    var data = JSON.parse(this.response);
    if(data['results']){
      data.results.forEach(film => {
        if(film['title']){
          console.log("film title : " + film.title);
        }
      });
    }  
  }
  request.send();
}
 
     
     
    