Skip to content

Instantly share code, notes, and snippets.

@jadaradix
Created June 2, 2017 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jadaradix/6c72a08a9e980676a141afd487e7516b to your computer and use it in GitHub Desktop.
Save jadaradix/6c72a08a9e980676a141afd487e7516b to your computer and use it in GitHub Desktop.
async-await-nodejs
'use strict';
async function boot () {
async function getName () {
if (false) {
return new Promise(
resolve => {
setTimeout(() => resolve('James'), 1000);
}
);
} else {
return Promise.reject('not working');
}
};
try {
let name = await getName();
console.log(`Name: ${name}`);
} catch (error) {
console.log(`Error: ${error}`);
}
};
boot();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment