Skip to content

Instantly share code, notes, and snippets.

@kypflug
Created September 25, 2015 23:28
Show Gist options
  • Save kypflug/9ff2b704dc08dc82bf22 to your computer and use it in GitHub Desktop.
Save kypflug/9ff2b704dc08dc82bf22 to your computer and use it in GitHub Desktop.
function httpGetJson(url) {
return spawn(function* () {
// check if the URL looks like a JSON file and call httpGet.
var regex = /\.(json)$/i;
if (regex.test(url)) {
// call the async function, wait for the result
return yield httpGet(url);
} else {
throw Error('Bad Url Format');
}
}, this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment