JSFiddle - React, Tailwind, and code Playground

JavaScript

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
} 
//Get latitude and longitude;
function successFunction(position) {
    var lat = position.coords.latitude;
    var long = position.coords.longitude;

    localStorage['authorizedGeoLocation'] = 1;
}

function errorFunction(){
    localStorage['authorizedGeoLocation'] = 0;
}

function checkauthorizedGeoLocation(){ // you can use this function to know if geoLocation was previously allowed
    console.log(localStorage['authorizedGeoLocation']);
    if(typeof localStorage['authorizedGeoLocation'] == "undefined" || localStorage['authorizedGeoLocation'] == 0 ) 
        return false;
    else 
        return true;
}

alert(checkauthorizedGeoLocation());