Skip to content
Snippets Groups Projects
Unverified Commit 38d1fde8 authored by GyDi's avatar GyDi
Browse files

fix: api error handle

parent dd78670a
No related branches found
No related tags found
No related merge requests found
...@@ -88,13 +88,9 @@ export async function updateProxy(group: string, proxy: string) { ...@@ -88,13 +88,9 @@ export async function updateProxy(group: string, proxy: string) {
// get proxy // get proxy
async function getProxiesInner() { async function getProxiesInner() {
try { const instance = await getAxios();
const instance = await getAxios(); const response = await instance.get<any, any>("/proxies");
const response = await instance.get<any, any>("/proxies"); return (response?.proxies || {}) as Record<string, ApiType.ProxyItem>;
return (response?.proxies || {}) as Record<string, ApiType.ProxyItem>;
} catch {
return {};
}
} }
/// Get the Proxy information /// Get the Proxy information
...@@ -151,24 +147,20 @@ export async function getProxies() { ...@@ -151,24 +147,20 @@ export async function getProxies() {
// get proxy providers // get proxy providers
export async function getProviders() { export async function getProviders() {
try { const instance = await getAxios();
const instance = await getAxios(); const response = await instance.get<any, any>("/providers/proxies");
const response = await instance.get<any, any>("/providers/proxies");
const providers = (response.providers || {}) as Record<
const providers = (response.providers || {}) as Record< string,
string, ApiType.ProviderItem
ApiType.ProviderItem >;
>;
return Object.fromEntries(
return Object.fromEntries( Object.entries(providers).filter(([key, item]) => {
Object.entries(providers).filter(([key, item]) => { const type = item.vehicleType.toLowerCase();
const type = item.vehicleType.toLowerCase(); return type === "http" || type === "file";
return type === "http" || type === "file"; })
}) );
);
} catch {
return {};
}
} }
// proxy providers health check // proxy providers health check
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment