Created
January 31, 2020 16:12
-
-
Save josephschmitt/176791755c54bb15a7352fcf254776af to your computer and use it in GitHub Desktop.
This file contains 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
// By default, use a try/catch with async await | |
try { | |
await someRemoteAction(); | |
} catch (e) { | |
console.error(e); | |
} | |
// If you need to store the result of an async/await AND you want the catch to be a specific value... | |
const myResult = await someRemoteAction().then(() => 'some-value').catch(() => 'some-error-value'); | |
// myResult will equal 'some-value' on success, but 'some-error-value' on error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment