Created
July 10, 2020 06:44
-
-
Save mcjcloud/dda9c6b6d2b586367df381efad17c3bd to your computer and use it in GitHub Desktop.
Asterisk Medium Article: todo router endpoint
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
/** | |
* POST /:id/uncomplete | |
* mark an existing to-do item as incomplete | |
*/ | |
todoRouter.post("/:id/uncomplete", async (req: Request, res: Response) => { | |
const { id } = req.params | |
try { | |
const todo = await uncompleteTodo(id) | |
if (!todo) { | |
return res.status(404).json({ error: "Item not found" }) | |
} | |
return res.status(200).json({ todo }) | |
} catch (error) { | |
return res.status(500).json({ error }) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment