express - How to write to response from HTTP Client Node.JS -


i have following...

var request = require('request');  exports.list = function(req, res){   res.send("listing"); }; exports.get = function(req, res){   request.get("<url>", function (err, res, body) {     if (!err) {       res.send(body,"utf8");     }   }); }; 

this fails following....

typeerror: object #<incomingmessage> has no method 'send' 

how do this?

update tried use write instead of send but...

/users/me/development/htp/routes/property.js:9   res.setheader('content-type', 'text/html');       ^ typeerror: object #<incomingmessage> has no method 'setheader' 

also writing out console instead works fine.

problem scope of variables, response output same name response object got in callback. changing around (resp vs res) made work....

exports.get = function(req, res){   request.get("<url>", function (err, resp, body) {     if (!err) {       res.send(body);     }   }); }; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -