Conditional If check

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"); 
} 

});

The fetch doesn’t return before these lines of code run:

	if (continent !== "europe") {
		wixLocation.to("/compliance");
	}

Therefore, continent is always either undefined or null and will therefore always be not-Europe.

Oh now I see it, what a stupid mistake. Logically the check must be done before the return. Thanks for the hint!

@sweetandsour can you please share your final code?