diff --git a/src/external/saveCountry.js b/src/external/saveCountry.js index aa1ad50..45c1f81 100644 --- a/src/external/saveCountry.js +++ b/src/external/saveCountry.js @@ -3,13 +3,15 @@ import axios from "axios"; const country_code = localStorage.getItem("country_code"); // const key = "02924c9a5a777f4d4854a45a326432c6"; - +const proxy = `https://cors.bridged.cc`; const GeoAPI = "https://ipapi.co/json/"; const fetchCountry = async () => { - const res = await axios.get(GeoAPI, { mode: "no-cors" }); + const res = await (await fetch(`${proxy}/${GeoAPI}`, { + method: "GET" + })).json(); // mode: "no-cors" don't return anything even if successfull // set the current country code in local stoarge - localStorage.setItem("country_code", res.data.country); + localStorage.setItem("country_code", res.country); }; if (!country_code) {