数组内无数据

时间:2019-07-19 11:49:59

标签: node.js

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

我试图通过打破循环来解决它,但是我所有的逻辑都失败了。

使数组列表为空,但其中包含数据。

0 个答案:

没有答案