Await

node v8.16.2
version: 1.0.1
endpointsharetweet
var got = URL => require("got")(URL, { json : true }); // Get the most popular repo asynchronously: "await" waits for it to finish! var response = await got("https://api.github.com/search/repositories?q=javascript&sort=stars&order=desc"); // Grab the contributors of the most popular repo, asynchronously var mostPopularRepo = response.body.items[0]; var contributors = (await got(mostPopularRepo.contributors_url)).body; // and render them as html contributors.reduce((prev, user) => prev + `<li><img src=${user.avatar_url} width=24 /> ${user.login} </li>` , "");
Created from: https://runkit.com/docs/await
Loading…

no comments

    sign in to comment