I am using node.js with express. There is a button that the user can click, and doing so calls this method on the server:
app.get('/getTime', function(req, res) {
var url = 'http://www.ctabustracker.com/bustime/api/v1/gettime';
http.get(url + '?key=' + apikey, function(resp) {
var xml = '';
resp.on('data', function(chunk) {
xml += chunk;
});
resp.on('end', function() {
console.log(xml);
res.send(xml);
});
});
});
This works, strictly speaking, in that the client side does receive the XML data. What bothers me is that there are two response objects that I have only dealt with by calling one "res" and the other "resp". I have a feeling I am handling the callbacks the wrong way, or that the entire structure of this task is done incorrectly.
I would appreciate some guidance about the "right way" to do this, as I am sure this is not it.