What is the best way to ensure that a callback passed to a method on a collection within a custom endpoint completes before the endpoint returns? Is there a way to block until the callbacks are called?
over 5 years ago
The best way is to use the async module to manage your code. You have to be careful that within each collection access callback, you call the defined async callback. Then, in the final callback of the async method, you call response.complete or response.continue.