Skip to content

Instantly share code, notes, and snippets.

@MaraAlexa
Created June 7, 2018 09:13
Show Gist options
  • Save MaraAlexa/1f8d92e2b8fe7837bbca83733a9cdeb8 to your computer and use it in GitHub Desktop.
Save MaraAlexa/1f8d92e2b8fe7837bbca83733a9cdeb8 to your computer and use it in GitHub Desktop.
const fetch = require("node-fetch");
async function showGitHubUser(handle) { // add async keyword
const url = `https://api.github.com/users/${handle}`;
const response = await fetch(url); // await takes in a promise and pauses the execution until the promise is settled
const user = await response.json(); // wait for the json response as well
console.log(user.name);
console.log(user.location);
}
showGitHubUser("mariusschulz");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment