Created
March 11, 2021 14:02
-
-
Save donavon/6a3070d8f94c6b8da19d42571005ef2a to your computer and use it in GitHub Desktop.
Maps over an array of Github usernames and returns an array of user objects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const githubUsernames = ['donavon', 'revelcw', '#^%$', 'sessionsfm']; | |
const fetchGithubUser = async (username) => { | |
const resp = await fetch(`https://api.github.com/users/${username}`); | |
return resp.ok ? await resp.json() : null; | |
} | |
const users = await Promise.all( | |
githubUsernames.map(fetchGithubUser) | |
); | |
users.forEach((user) => { | |
console.log(user?.name); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment