Get a json via Http Request in NodeJS

后端 未结 3 755
终归单人心
终归单人心 2020-12-07 20:17

Here is my model with a json response:

exports.getUser = function(req, res, callback) {
    User.find(req.body, function (err, data) {
        if (err) {
           


        
3条回答
  •  醉梦人生
    2020-12-07 20:36

    http sends/receives data as strings... this is just the way things are. You are looking to parse the string as json.

    var jsonObject = JSON.parse(data);
    

    How to parse JSON using Node.js?

提交回复
热议问题