Skip to content

Instantly share code, notes, and snippets.

@irridescentrambler
Last active May 25, 2019 13:24
Show Gist options
  • Save irridescentrambler/2d6b5883383e641ec826ced626617f55 to your computer and use it in GitHub Desktop.
Save irridescentrambler/2d6b5883383e641ec826ced626617f55 to your computer and use it in GitHub Desktop.
function callDogApi(url){
const promise = fetch(url);
promise.then((response)=> {
if(response.status === 200){
console.log('Api call successful');
console.log(response);
}else{
throw new Error(response.status);
}
}).catch((error)=> {
console.log(error);
});
}
callDogApi("https://dog.ceo/api/breed/ABD/images/random");
callDogApi("https://dog.ceo/api/breed/Husky/images/random");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment