Last active
July 19, 2018 13:25
-
-
Save naijab/ad61d8ede089b746caa548d806ebb88e to your computer and use it in GitHub Desktop.
How to aync await
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 characters
getFetchPromiseFake = (isHaveError) => { | |
return new Promise((resolve, reject) => { | |
if (isHaveError) { | |
reject(new Error('Error Something')) | |
} else { | |
resolve('Successfake data: ...') | |
} | |
}); | |
} | |
testFakePromise = async () => { | |
try { | |
const result = await getFetchPromiseFake() | |
console.log(result) | |
} catch (error) { | |
console.error(error) | |
} | |
} | |
testFakePromise() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment