JSON object persisting state from previous calls in nodejs express
This approach is generally a bad idea.
- It doesn't work if you ever want to scale beyond 1 server.
- It doesn't work when there's more than 1 user using the system at the same time.
The right way to handle something like this is by adding either a database, or a session system.
Sessions feels like the right approach here, because that concept is specific for letting you store information specific to a user, and store/retrieve that over the course of several requests.