Reputation: 1450
I have a page in a tabular form where I have a controller defined for one row and based on the column value I set some variables inside my controllers appropriately.
But when I try to initiate multiple requests to the same controller in different columns immediately one after the other, the responses sent from the node server is getting mixed up. The response that should actually to column 1 is messing up with column 3 and so on(same columns share the same controller except some variable values being set). Is there a way I can ensure that my responses are safe and don't intermingle with each other?
Upvotes: 0
Views: 288
Reputation: 3
I'm gonna throw this possibility out there that maybe you are using a const to hold the results and some other function you are running at the same time (like an app loading a dashboard with multiple queries happening at once) is using that same variable and overwriting it since the scope is larger than just a single function.
Upvotes: 0
Reputation: 1718
Use promises that will allow you to resolve the issue asynchronous javascript problems, moreover you can also use promise.all to resolve all the requests and then respond back with appropriate data.
Upvotes: 1