April 2020
Intermediate to advanced
716 pages
18h 55m
English
The edit functionality is very similar to the create product functionality we implemented earlier. The EditProduct form component, which can be implemented to render a form that allows product detail modification, will also only be accessible by verified sellers at /seller/:shopId/:productId/edit.
To restrict access to this view, we can add a PrivateRoute in MainRouter to declare the route to the EditProduct view as follows:
mern-marketplace/client/MainRouter.js:
<PrivateRoute path="/seller/:shopId/:productId/edit" component={EditProduct}/>
The EditProduct component contains the same form as NewProduct, but with populated values of the product retrieved using the read product API. On form submit, it uses a fetch method to send multipart ...
Read now
Unlock full access