Skip to content

Instantly share code, notes, and snippets.

@arturom
Created January 6, 2016 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturom/3140250c988ff7310102 to your computer and use it in GitHub Desktop.
Save arturom/3140250c988ff7310102 to your computer and use it in GitHub Desktop.
function importLodash() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js';
document.body.appendChild(s);
}
function toURL(id) {
return '/test/reprocess_asset/' + id;
}
function toAjaxPromise(url) {
return $.get(url);
}
var ids, promises, responses;
importLodash();
ids = [4810627,4810545,4810622];
promises = _(ids)
.map(toURL)
.map(toAjaxPromise)
.value();
responses = _(promises)
.pluck('responseText')
.map(JSON.parse)
.value();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment