Skip to content

Instantly share code, notes, and snippets.

@patarkf
Last active June 12, 2017 14:43
Show Gist options
  • Save patarkf/86e89b72e0e28afd8fb52f2e703c4784 to your computer and use it in GitHub Desktop.
Save patarkf/86e89b72e0e28afd8fb52f2e703c4784 to your computer and use it in GitHub Desktop.
Promise request example
function getFromGitHub() {
const userName = 'patarkf';
const url = 'https://api.github.com/users';
fetch(`${url}/${userName}/repos`)
.then(reposResponse => {
return reposResponse.json();
})
.then(userRepos => {
console.log(userRepos);
})
.catch(err => {
console.log(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment