title: fetch movie data from API's in javascript
body: <p>I have a json object of >15k movies containing IMDb ID's like this</p>
  
  <pre><code>0: ObjectID: "1."
     IdIMDb: "tt2322441"
     Title: "Fifty Shades of Grey"
     Year: 2015
  1: ObjectID: "2."
     IdIMDb: "tt1617661"
     (...)
  </code></pre>
  
  <p>And I'm looking to complete this data with data from other api's</p>
  
  <ul>
  <li>Poster, Runtime, Genres, Directors... can be found here <a href="http://www.omdbapi.com/?i=tt0111161&amp;plot=short&amp;r=json" rel="nofollow">http://www.omdbapi.com/?i=tt0111161&amp;plot=short&amp;r=json</a></li>
  </ul>
  
  <p>My question is: what is the most efficient manner to complete my data with data from this api ?<br>
  I plan to run this program only once and store the result so it can respect api restrictions.</p>
  
  <p>My first idea was to do something like this</p>
  
  <pre><code>data.forEach(function (d, i) {
      d.Poster = OMDbApi(d.IdIMDb);
      ...
  }
  
  function OMDbApi(i) {
      $.ajax({
          url:"http://www.omdbapi.com/?i="+i+"&amp;plot=short&amp;r=json",
          crossDomain: true,
          dataType: "jsonp",
          success: function (response) {
              return response.Poster;
          },
          error: function(XMLHttpRequest, textStatus, errorThrown) { 
              error = 1;
          } 
      });
  }
  </code></pre>
  
  <p>Thank you for any help you can provide :-)</p>