May 2018
Intermediate to advanced
470 pages
13h 54m
English
If the create order API is successful, we will empty the cart using an emptyCart helper method in cart-helper.js.
mern-marketplace/client/cart/cart-helper.js:
emptyCart(cb) { if(typeof window !== "undefined"){ localStorage.removeItem('cart') cb() }}
The emptyCart method removes the cart object from localStorage, and updates the state of the view by executing the callback passed.
Read now
Unlock full access