My situation is like this, I have a server like this and inside I am
calling another callback function which gets multiple values:
var http = require('http');
var server = http.createServer(req,resp) {
var finalVal = "";
consumer.on('message',function(message) {
finalVal = message;
console.log(finalVal);
});
resp.end(finalVal);
});
My finalVal should display all the multiple values it fetches and send it
as a response, but problem is it's sending only first value where as
console.log displays all the values. I do understand that by the time
consumer.on ends response would have committed. Can someone please help me
how to handle this scenario since I'm very new to Node.js ? Currently due
to heavy deadlines I don't have time to read full information about
callbacks. But defnitely I would take time to learn about callbacks.
Here `consumer.on` calls multiple times till it fetches all the data from
backend, I need to send all those data in a final response. I am using
`node-kafka` to consume to kafka messages.
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/9cf99828-576a-4327-b700-6fedb62c7785%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.