refactor: ip api
This commit is contained in:
@@ -67,11 +67,11 @@ export const serverApi = createApi({
|
|||||||
}),
|
}),
|
||||||
getIfInChina: builder.query<boolean, void>({
|
getIfInChina: builder.query<boolean, void>({
|
||||||
query: () => ({
|
query: () => ({
|
||||||
url: `https://ipapi.co/json`
|
url: `https://cf-props.ihacker.dev`
|
||||||
}),
|
}),
|
||||||
transformResponse: (resp: IPData) => {
|
transformResponse: (resp: IPData) => {
|
||||||
if (!("error" in resp)) {
|
if (!("error" in resp)) {
|
||||||
return resp.country_code.toUpperCase() == "CN";
|
return resp.country.toUpperCase() == "CN";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,4 +15,4 @@ export type Price = {
|
|||||||
type: PriceType;
|
type: PriceType;
|
||||||
sub_dur?: PriceSubscriptionDuration;
|
sub_dur?: PriceSubscriptionDuration;
|
||||||
};
|
};
|
||||||
export type IPData = { error?: boolean; country: string; country_code: string };
|
export type IPData = { error?: boolean; country: string };
|
||||||
|
|||||||
Reference in New Issue
Block a user