Last active
December 7, 2016 13:21
-
-
Save aherve/847e01103e90349b6b14b0dd8553125d to your computer and use it in GitHub Desktop.
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
| async function notSure (userId: string | null): Promise<null | User> { | |
| if (!userId) { return null } // e.g. return void | |
| const user = await User.findById(userId) // this return the result of the promise of findById | |
| if (user) { return user } | |
| throw 'User not found' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment