I'm using the intl-tel-input module to have validation for the phone field of a form that will be filled by store employees in different countries.
The validation works well, but I need to set the code area automatically once the store employees log into the form with the good country (e.g store located in Paris need to have the french code area).
For the moment, I'm using geoIpLookup with the following function:
geoIpLookup: function(callback) {
fetch('https://ipinfo.io/json', {
cache: 'reload'
}).then(response => {
if ( response.ok ) {
return response.json()
}
throw new Error('Failed: ' + response.status)
}).then(ipjson => {
console.log('IPINFO SUCCESS')
callback(ipjson.country)
}).catch(e => {
console.log('IPINFO ERROR')
callback('fr')
})
}
It works but geoIpLookup checks the IP of the device, using the wifi. But the employees in the store will be using a VPN that may display a country different than the one where the store is located.
To be clear, the store may be in France but the ip will be located in Spain. So the good code area won't be shown.
Is there another way to set it automatically without using IP location?
Hope I made myself clear, and thanks in advance.