This is my first project , I am building a RESTful API using Loopback Nodejs framework. Users can add and remove items from their carts but need to be authenticated to pay. How do I deal with that ? Should I :
- post and save the current cart in the database and every time a user adds an item I post it to the database
- Or store the current cart on the client side until the user pays I post it to the database
- Or post items and save them in a memory cache
- Is it better to have an Api endpoint like myapp.com/cart and get the current cart using user token or myapp.com/cart/{id} ?