mirror of https://github.com/VERT-sh/VERT.git
fix: what the flip ipapi
This commit is contained in:
parent
dbeb0eee79
commit
a8366b3cb3
|
@ -31,17 +31,50 @@ export interface IpInfo {
|
|||
}
|
||||
|
||||
export const ip = async (): Promise<IpInfo> => {
|
||||
if (browser) {
|
||||
const item = localStorage.getItem("ipinfo");
|
||||
if (item) {
|
||||
return JSON.parse(item);
|
||||
try {
|
||||
if (browser) {
|
||||
const item = localStorage.getItem("ipinfo");
|
||||
if (item) {
|
||||
return JSON.parse(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const res = await fetch("https://ipapi.co/json/").then((r) => r.json());
|
||||
if (browser) {
|
||||
localStorage.setItem("ipinfo", JSON.stringify(res));
|
||||
}
|
||||
const res = await fetch("https://ipapi.co/json/").then((r) => r.json());
|
||||
if (browser) {
|
||||
localStorage.setItem("ipinfo", JSON.stringify(res));
|
||||
}
|
||||
|
||||
return res;
|
||||
return res;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (_) {
|
||||
return {
|
||||
ip: "127.0.0.1",
|
||||
asn: "AS0",
|
||||
city: "Localhost",
|
||||
continent_code: "NA",
|
||||
country: "US",
|
||||
country_calling_code: "+1",
|
||||
country_capital: "Washington",
|
||||
country_code: "US",
|
||||
country_code_iso3: "USA",
|
||||
country_name: "United States",
|
||||
country_population: 0,
|
||||
currency: "USD",
|
||||
currency_name: "Dollar",
|
||||
languages: "en-US,es-US,haw,fr",
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
network: "Unknown",
|
||||
postal: "00000",
|
||||
region: "Local",
|
||||
region_code: "LOC",
|
||||
country_area: 0,
|
||||
timezone: "America/New_York",
|
||||
utc_offset: "-0500",
|
||||
version: "IPv4",
|
||||
in_eu: false,
|
||||
org: "Localhost",
|
||||
country_tld: ".us",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue