I have a function:
getCoordinates: function() {
geoLocation.getCurrentLocation().then(function(location) {
return "latitude: " + location.latitude + " longitude:" + location.longitude;
});
}
Which returns undefined, but when I instead do:
getCoordinates: function() {
geoLocation.getCurrentLocation().then(function(location) {
console.log("latitude: " + location.latitude + " longitude:" + location.longitude);
});
}
and run the same function I get:
"latitude: 4X.XXXXXX longitude:-12X.XXXXXXX"
I don't understand why it is returning undefined when the data must be defined or it wouldn't log to the console. Is this some kind of timing issue? What am I missing?