Think in My Country I have 3states.
I will show my Website in 1st State.
And Will be block for next 2 State.
Show Website on a Specific IP.
How to do using wix code?
Think in My Country I have 3states.
I will show my Website in 1st State.
And Will be block for next 2 State.
Show Website on a Specific IP.
How to do using wix code?
You can use the geolocation API , and then do a lookup to find the country. See the Google Places example for information on how to do that.
You can get the user’s IP by using one of the online IP lookup services. Something like this:
import {fetch} from 'wix-fetch';
$w.onReady(function () {
fetch('https://extreme-ip-lookup.com/json', {
method: 'get'
})
.then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
}
})
.then((json) => {
console.log('returned json', json);
const ipaddress = json.query;
console.log('ip address', ipaddress);
$w('#txtUserIP').text = ipaddress;
const country = json.country;
console.log('country', country);
$w('#txtCountry').text = country;
return country; // return whatever json field you want here
});
});
You can use whatever field (including country, IP, etc) from the returned JSON that you want.