May 2018
Intermediate to advanced
470 pages
13h 54m
English
The edit functionality is very similar to create product and the EditProduct form component is also only accessible by verified sellers at /seller/:shopId/:productId/edit.
mern-marketplace/client/MainRouter.js:
<PrivateRoute path="/seller/:shopId/:productId/edit" component={EditProduct}/>
The EditProduct component contains the same form as NewProduct with populated values of the product retrieved using the read product API, and it uses a fetch method to send multipart form data with a PUT request to the edit product API in the backend at /api/products/by/:shopId.
mern-marketplace/server/routes/product.routes.js:
router.route('/api/product/:shopId/:productId') .put(authCtrl.requireSignin, shopCtrl.isOwner, productCtrl.update)
The update ...
Read now
Unlock full access