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

JavaScript REST APIs with Express Create, Read, Update, Delete Edit A Quote

1 Answer

Tyler McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tyler McDonald
Full Stack JavaScript Techdegree Graduate 16,700 Points

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.

https://www.geeksforgeeks.org/difference-between-put-and-patch-request/

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

HI Tyler McDonald, thank you for taking time and explaining.\

I still have 2 questions -

1 - 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. In this Resource means The data right? 2 - So how about if I just want to change a specific Part of the Data, we have to make sure that every part is updated or we have to copy the other parts of the data and this implies extra code?