3 ms·
Manually, you could structure it in several functions like prepare_response() and render_response(), possibly with other functions in-between for the various ch
by aGHz 14y ago
Manually, you could structure it in several functions like prepare_response() and render_response(), possibly with other functions in-between for the various chunks of data you need in your response. When all the chunks are ready, you finally call render_response() and send it.
In practice, you can find a ton of libraries that can help you manage this [1], I -believe- the most recommended one would be 'futures'.
[1] https://github.com/joyent/node/wiki/modules#wiki-async-flow https://github.com/joyent/node/wiki/modules#wiki-async-flow