Skip to content

Instantly share code, notes, and snippets.

@macloo
Last active October 31, 2019 22:13
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 macloo/8b2bc58ffd4c792a974d4b78461f098d to your computer and use it in GitHub Desktop.
Save macloo/8b2bc58ffd4c792a974d4b78461f098d to your computer and use it in GitHub Desktop.
Short and sweet example of using fetch and an API
// from https://frontendmasters.github.io/bootcamp/ajax - more info there
const BREEDS_URL = "https://dog.ceo/api/breeds/image/random";
const promise = fetch(BREEDS_URL);
promise
.then(function(response) {
const processingPromise = response.json();
return processingPromise;
})
.then(function(processedResponse) {
console.log(breeds);
});
console.log("this will log first");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment