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