0
exports.getLatLng = function(attractionId, attractionName){
    googleMapsClient.geocode({address: attractionName}).asPromise()
        .then((response) => {
            tmp = response.json.results;
            return (tmp);

         })
    .catch((err) => {
        console.log(err);
    });
}

exports.correctDataWOLatLng = function(){
model.getMySQLDataWOLatLng().then(function(result) {
    console.log(result); //will log results.

    this.getLatLng(0, "lalbagh bangalore"); // Line that gives the error
    });

};

I'm getting the following error: (node:9361) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'getLatLng' of undefined

My aim is to call the getLatLng() function in the above code.

0 Answers0