2020年12月22日星期二

Node.js res.end contents are sent in res.config.data instead of res.data

Front end guy going fulls tack here... can't figure out why my response values end up in res.config.data instead of res.data. Below is my code.

  addEngineer(req, res) {      MongoClient.connect(url, function (err, client) {        let finalRes;        if (err) {          throw err;        } else {          let db = client.db(dbName);          db.collection("Engineers")            .insertOne({              Name: req.body.name,              Email: req.body.email,              Status: req.body.status,              Specialty: req.body.specialty,            })            .then((result) => {              finalRes = result;              console.log(result);            });          client.close();        }        res.status(200).end(finalRes);      });    },  
https://stackoverflow.com/questions/65417825/node-js-res-end-contents-are-sent-in-res-config-data-instead-of-res-data December 23, 2020 at 09:05AM

没有评论:

发表评论