1

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 :

  1. post and save the current cart in the database and every time a user adds an item I post it to the database
  2. Or store the current cart on the client side until the user pays I post it to the database
  3. Or post items and save them in a memory cache
  4. 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} ?
Bruce_Wayne
  • 19
  • 1
  • 5
  • 2
    I would suggest to store carts on the client side. For example use local storage: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage – Eska Nov 29 '17 at 18:32
  • try using `loopback-context` - https://github.com/strongloop/loopback-context – lazzy_ms Aug 09 '19 at 06:36

0 Answers0