Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@KevinTCoughlin
Forked from up1/async.js
Created September 22, 2018 07:21
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 KevinTCoughlin/b62ec33c9cfc896db0806219cafa78e8 to your computer and use it in GitHub Desktop.
Save KevinTCoughlin/b62ec33c9cfc896db0806219cafa78e8 to your computer and use it in GitHub Desktop.
NodeJS with Async/Await
var fetch = require('node-fetch')
async function getDataFromAPI() {
let response = await fetch("https://api.github.com/users/up1")
let data = await response.json()
console.log(JSON.stringify(data, null, "\t"))
}
getDataFromAPI()
var fetch = require('node-fetch')
function getDataFromAPI() {
return fetch("https://api.github.com/users/up1")
.then(response => response.json())
.then(data => console.log(JSON.stringify(data, null, "\t")))
}
getDataFromAPI()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment