Problem is the response in res.send is undefined.
app.get('/products', function(req, res) { | |
var Client = http.createClient(80, 'local.10layer.com'); | |
var request = Client.request("GET", '/workers/api/section/products', {'host' : 'local.10layer.com'}); | |
request.addListener("response", function(response) { | |
var body = ""; | |
response.addListener("data", function(data) { //Add listener for the actual data | |
body += data; //Append all data coming from api to the body variable | |
}); | |
response.addListener("end", function() { //When the response ends, do what you will with the data | |
var response = JSON.parse(body); //In this example, I am parsing a JSON response | |
console.log(response); | |
}); | |
}); | |
request.end(); | |
res.send(response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment