Not sure if you're still monitoring this thread [no HN notifications, eh?], but here's my question:
My get_username() function, say I have this code:
var server = http.createServer(function(req, res) {
username = get_username();
res.writeHead(200);
res.write("<html>");
res.write("You are " + username);
res.end("bye");
This obviously won't work, res.end() gets fired long before my DB query in get_username() finishes. How else would I accomplish what I'm trying to do here other than putting my response stuff in the DB query's callback function?<Sorry for the newb question, buy what I'm doing: having the response generated inside of the query's callback, seems to be the way most of these node tutorials suggest.>