mirror of https://github.com/VERT-sh/VERT.git
fix: ipapi 429
This commit is contained in:
parent
82a63929b4
commit
dbeb0eee79
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
export interface IpInfo {
|
export interface IpInfo {
|
||||||
ip: string;
|
ip: string;
|
||||||
network: string;
|
network: string;
|
||||||
|
|
@ -29,5 +31,17 @@ export interface IpInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ip = async (): Promise<IpInfo> => {
|
export const ip = async (): Promise<IpInfo> => {
|
||||||
return await fetch("https://ipapi.co/json/").then((r) => r.json());
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue