function fetchEmail(githubUsername) {
return fetch(`https://api.github.com/users/${githubUsername}`)
.then((response) => response.json())
.then((profile) => {
return profile.email;
})
.catch((reason) => {
console.log(`Couldn't fetch username`, reason);
throw reason;
});
}
async function fetchEmail(githubUsername) {
try {
let response = await fetch(`https://api.github.com/users/${githubUsername}`);
let profile = await response.json();
return profile.email;
} catch (reason) {
console.log(`Couldn't fetch username`, reason);
throw reason;
}
}