Last active
May 25, 2017 07:41
-
-
Save aherve/8addcf4e7df5f13e3abbfc39acecd0ac 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
| import { Request, Result } from 'express' | |
| export async function showUser (req: Request, res: Result) { | |
| try { | |
| const user = await User.findOne({id: req.params.id}) | |
| if (user) { | |
| res.status(200).send({user}) | |
| } else { | |
| res.sendStatus(404) | |
| } | |
| } catch (e) { | |
| res.status(500).send({error: e}) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that you meant
import { Request, Response } from 'express'on the first line import and on(req: Request, res: Response)function declaration. :)