Created
August 4, 2019 09:52
-
-
Save mattiaslundberg/b7d6b6b0933bb59bc4aa2b9f29da0ccc to your computer and use it in GitHub Desktop.
Revisions
-
mattiaslundberg created this gist
Aug 4, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ // Create new promise const p = new Promise((resolve, reject) => { reject(new Error('some error')); //resolve('Some data'); }); // Then/catch p.then(result => console.log(result)).catch(error => console.error(error)); // Async const foo = async () => { try { const result = await p; console.log(result); } catch (error) { console.log('it crashed', error); } }; foo();