For some reasons, my check if (continent !== “europe”) works inverse. So when ever a user is from europe, he will be redirected to my compliance page. It should work exactly the other way round so only users outside of Europe should be redirected to the compliance page. What’s wrong here?
import wixLocation from ‘wix-location’;
import {fetch} from ‘wix-fetch’;
$w.onReady(function () {
let continent;
let country;
fetch('json-url', {
method: 'get'
})
.then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
}
})
.then((json) => {
continent = json.continent.toLowerCase()
country = json.countryCode.toLowerCase()
return continent;
});
if (continent !== "europe") {
wixLocation.to("/compliance");
}
});