let promises = [];
function getNotificationArray (callback){
_.forEach(data, (d) => {
let distanceData = getDistanceFromLatLonInKm(d.latitude, d.longitude, lat, long);
if (distanceData < range || distanceData == range) {
Business.getBusinessListingById(d.id, (err, resp) => {
if (err) {
result(err, null)
} else {
promises.push(resp[0])
}
})
}
})
callback();
}
getNotificationArray( function() {
result(null, promises)
});
here I am getting empty array but its having data
我试图通过打破循环来解决它,但是我所有的逻辑都失败了。
使数组列表为空,但其中包含数据。