-
-
Save kasramp/84b67d4db830944c622dc84eeb4b60ed 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
router.get("/v1/users/:id", async (context) => { | |
if (context.params && context.params.id && !isNaN(parseInt(context.params.id))) { | |
const user = (await storage.getUserById(context.params.id))[0]; | |
if (!user) { | |
context.response.status = 404; | |
context.response.body = { error: `User ${context.params.id} not found` }; | |
} else { | |
context.response.body = user; | |
} | |
} else { | |
context.response.status = 400; | |
context.response.body = { error: "Id must be number" }; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment