Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
karan BadhwarWeb Development Techdegree Graduate 18,135 Points
PUT or PATCH
Will it be better if we use Patch instead of Put? Which one would have been better?
I think in this case PUT is used for the sake of example and because it's more common than PATCH. But from I have read, the main difference is that PUT updates the entire resource, whereas PATCH only updates specified fields within the resource. PATCH therefore is the more specific HTTP method, and PUT is a more straightforward approach to updating a resource. In my understanding PATCH is like a "sub-method" of PUT. PUT can do everything that PATCH can do, but not the opposite.
Another thing worth mentioning is that if you send multiple PUT requests to the same resource, there will still only be one of that resource. However, sending multiple PATCH requests to a resource would create separate resource altogether.
Also, PUT uses more bandwidth than PATCH, which would seemingly give PATCH some good uses cases in certain situations that involve updating large resources.