Created
March 9, 2026 10:02
-
-
Save kieranbarker/ecd057142af784ffe54fb5676702937a 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
| app.patch("/books/:id", (req, res) => { | |
| // Attempt to find the book. | |
| let book = findBook.get({ id: req.params.id }); | |
| // If the book doesn't exist, send an error. | |
| if (!book) { | |
| res.status(404).json({ errors: ["Book not found"] }); | |
| return; | |
| } | |
| // Otherwise, update the book. | |
| const updates = { ...book, ...req.body }; | |
| updateBook.run(updates); | |
| book = findBook.get({ id: req.params.id }); | |
| res.status(200).json(book); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment