I just want to return 1 and return 0 at the specified places. I've looked at numerous sources but was unable to solve this issue.
Below is the code :
exports.getLatLng = function(row){
var attractionId = row['attractionid'];
var attractionName = row['attractionname'] + ' ' +
row['Destination_name'];
var googleMapsResults;
return googleMapsClient.geocode({address: attractionName}).asPromise()
.then((response) => {
googleMapsResults = response.json.results[0];
// console.log(googleMapsResults);
model.dumpIntoMongo(attractionId, googleMapsResults);
// var y=tmp[0];
var latitude = googleMapsResults.geometry.location.lat;
var longitude = googleMapsResults.geometry.location.lng;
row["id"] = parseInt(attractionId);
// delete row['attractionid'];
delete row['destination_id'];
delete row['destination_name'];
delete row['attraction_id'];
delete row['success'];
// row["lat"] = latitude;
// row["lon"] = longitude;
row["latlon"] = latitude.toString() + "," + longitude.toString();
exports.indexIntoSolr(row);
return 1; //return 1
})
.catch((err) => {
console.log(err);
return 0; // return 0
});
}