Rather than send that info back at this line:
res.send(JSON.stringify(data, undefined, 2));
Define another function, below, such as:
function nextDBQuery(data)
//query db, do more stuff, yada yada,
//pass on to another similar function
}
And send your data there with:
nextDBQuery(data);
Basically, instead of res.send()
ing your first set of data, pass it on to another function, or just do all the work inside there and have a lot of callbacks.