Just dipping my toes into the world of VueJS. I've got a side project in the works that hinges on fetching User's Geolocation Data right after the main component has mounted.
My code snippet is as follows:
var app = new Vue({
el: '#app',
data: {
position: null
},
mounted: function() {
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
this.position = position.coords;
})
}
}
});
I've been attempting to update the position
in the data object with the current geolocation upon mounting, however, it doesn't seem to be working. Am I overlooking something?