Updating a Resource - PATCH /todos/:id
The delete
route is now set up and tested, so it's time to start on the final route for managing our Todo resources. This is going to be the route that lets you update a Todo item whether you want to change the text to something else or whether you want to toggle it as completed. Now this is going to be the most complex route we write; everything so far has been relatively straightforward. We're going to need to do a few extra things to get this updating route to work as expected.
The first thing I want to do before we go ahead and create the route down below is install that Lodash library we used in one of the previous sections for this course.
Installing Lodash library
If you remember, Lodash provides a few really great utility functions and we'll be taking advantage of a couple of those inside of our update route. Right in the Terminal, I'm going to use npm i
with the --save
flag to install it; the module name itself is called lodash
, and we'll be using...