I am using below code but its show..below picture type data i want document of job.. how to do this please help me. i want to show response in local variable. I am using nodejs moongoose schema and promises
export function getresult(req, res) {
Job.findById(req.params.id)
.exec()
.then(GetdifferenceResult(res))
.catch(errorhand(res));
}
function GetdifferenceResult(response, statusCode) {
console.log('job', response);
var GetData = response;
}
Output:
Code issue fixed but it shows the error now:
TypeError: Unknown encoding: 1
Just don't pass any parameter in GetdifferenceResult
:
Job.findById(req.params.id)
.exec()
.then(function (_job) {
console.log('job', _job);
res.send(_job); //send response to client
})
.catch(errorhand(res));
It is the problem with npm bson 1.0.2
.
Solution: update bson to version 1.0.3:
npm install bson@1.0.3