From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Updating a product: PUT

Updating a product: PUT

Hello and welcome back. In this video, we learn how we can update a product using a put request. So the put request basically replaces the whole product that we have given to it, while the batch request that we discussed can update only specific fields. So consider as it, if we are going to provide a whole object, and we are using the put method, And that means we are basically replacing everything inside the product item that we are sending off. So it will replace the price, description and name everything. But if we are, if we just have to update only a specific field, then we should be using the patch method instead. So consider if we just want to update the price and add it to 5 from 6, then we need to use the patch update. So by convention, this should be the methods that we should be using. For updating a product, we have to create a edit product or update product component. This will have a update handler and this will have a form open just like the add product. In that form…

Contents