Skip to content

Instantly share code, notes, and snippets.

@kypflug
Created September 25, 2015 23:28
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 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