node.js - Node js request module get different type (format) of return value from server? -
i use request library access web service, found return value can different.
exports.getuserbyemail = function(req, res) { request.get(endpoint + req.params.email, function(error, response, user) { console.log((typeof user)) // type of user string ... logic }) } exports.login = function(req, res) { request.post(endpoint + 'login', {json: { email: req.body.email, password: req.body.password }}, function(error, response, user) { console.log((typeof user)) // type of user object ... logic }) }
on server side, returns json, e.g.
{ username: "user", password: "hashedpassword", ...... }
can tell me why .get , .post method gives me different types of return value?
i figured out, sorry stupid question. forgot set {json:true} option in method.
Comments
Post a Comment