I need to fetch the user's location using axios from http://ip-api.com/json and based on it I've to conditionally render different content on the website. Its working fine on localhost(npm start) but when its deployed I get an axios network error. What can actually be the reason for this as I haven't encountered such an error.
const getGeoInfo = () => {
axios
.get("http://ip-api.com/json")
.then((res) => {
setRegion(res.data.regionName);
if (res.data.country === "Canada" || res.data.country === "Pakistan") {
setAcceptedCountries(true);
} else setAcceptedCountries(false);
})
.catch((err) => {
console.log(err);
});
};