Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CORS issue and removed Axios Support #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/external/saveCountry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down