Привет, я новичок в nodejs и mongoDB. Я не получаю значение во внешний обратный вызов из внутреннего обратного вызова, который находится в al oop. Я пробовал использовать следующий код
getDoctorsSchedules(req,res){
console.log("*** All Doctor's Schedule...");
doctorsschedulesRepo.getDoctorsSchedules(req.body,(err, data) => {
if (err) {
console.log("***All Doctor's Schedule Schedule: " + util.inspect(err));
res.json({
states: null
});
} else {
console.log('*** All Doctor Schedule ok');
if(data)
{
var reslt;
reslt = function(data ,callback){
var r = [];
for( let i in data)
{
r[i] = data[i].toObject();
//fetch doctors details by doctor's id
doctorRepo.getDoctorListbyID(data[i].DoctorID,(err, result)=>{
if (err) {
console.log('---- DOCTOR ' + util.inspect(err));
} else {
if(result){
r[i].Doctors = result;
console.log(r[i].Doctors);
callback(r[i].Doctors);
}
}
});
}
}
res.json({"success":true,"data":reslt});
}
}
});
}
На самом деле я пытаюсь получить данные по идентификатору из внутреннего обратного вызова, и эти идентификаторы заполняются как массив json во внешнем обратном вызове.
Заранее спасибо