Im currently having trouble getting the output below. Can somebody tell me what is wrong with the code that prevents me from getting the following output that i want? Thanks in advance!
Code:
 // http requests
 const getJSON = require('get-json');
 function getShopLocation(postalCode) {
 // Use promise to resolve when success
 return new Promise((resolve, reject) => {
 // One Map API is used to retrieve Lat & Lon & more map details
 var oneMapURL = `https://developers.onemap.sg/commonapi/search?searchVal=${postalCode}&returnGeom=Y&getAddrDetails=Y&pageNum=1`;
 getJSON(oneMapURL, function(error, response) {
 if (response) {
  // Get only the lat
  var lat = response.results[0].LATITUDE;
  // Resolve the location details
  resolve(lat);
} else {
  reject(error);
}
});
});
}
 function init() {
    var postalCode = [ 519498, 629117, 670445, 258748, 238884 ];
    var title = ['Place A', 'Place B', 'Place C', 'Place D', 'Place E'];
    var data = [];
    var i = 0;
    for (i = 0; i < postalCode.length; ++i) {
        var lat = getShopLocation(postalCode[i]);
        data.push({ title: title[i] , lat: lat});
    }
    Promise.all(data)
    .then((results) => {
        console.log("Data Output: ", results);
    })
    .catch((e) => {
        // Handle errors here
        console.log(error);
    });
    }
    init();
Output I want:
[
  { title: 'Place A', lat: 1.322595392 },
  { title: 'Place B', lat: 1.325617641 },
  { title: 'Place C', lat: 1.325617641 },
  { title: 'Place D', lat: 1.3835802030000002 },
  { title: 'Place E', lat: 1.3061957990000002 }
]
 
     
    