Creating a cart on the front end with the Django Ecommerce backend API

After taking the Django course I have decided to implement the frontend of the Ecommerce API . so can I create the cart by sending a post request in a useEffect hook? Or is there a better way? Because I need the ID of the cart to enable send post request to the cart items endpoint since it is a nested url