Skip to content

Instantly share code, notes, and snippets.

@mcjcloud
Created July 10, 2020 06:44
Show Gist options
  • Save mcjcloud/dda9c6b6d2b586367df381efad17c3bd to your computer and use it in GitHub Desktop.
Save mcjcloud/dda9c6b6d2b586367df381efad17c3bd to your computer and use it in GitHub Desktop.
Asterisk Medium Article: todo router endpoint
/**
* 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