Create a gist now

Instantly share code, notes, and snippets.

@pionize /.js
Created Jul 25, 2017

What would you like to do?
conditional if, promise vs async/await
//implements Promise way
const getUserPromise = (name) => {
return getUserByName('andrew')
.then(function (user) {
if (user.role == 'guest') {
return user;
} else {
return false;
}
})
}
//implements Async/Await way
const getUserAsync = async (name) => {
const user = await getUserByName(name);
if (user.role == 'guest') {
return user;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment