node fetch

node v4.9.1
version: 1.0.0
endpointsharetweet
const fetch = require("node-fetch") var getUserDetails = function foo (url) { return fetch(url) .then(function(res) { return res.json() }) }
'await' the promise from the above cell. Destructure the response into variables to build a string
const businessCard = await getUserDetails('https://api.myjson.com/bins/21jy8') const {name, blog, location} = businessCard "Name: " + name + ", Blog: " + blog + ", Location: " + location
Loading…

no comments

    sign in to comment