fix: api error handle

This commit is contained in:
GyDi 2022-10-11 22:51:18 +08:00
parent dd78670a4b
commit 38d1fde84f
No known key found for this signature in database
GPG Key ID: 58B15242BA8277A6

View File

@ -88,13 +88,9 @@ export async function updateProxy(group: string, proxy: string) {
// get proxy
async function getProxiesInner() {
try {
const instance = await getAxios();
const response = await instance.get<any, any>("/proxies");
return (response?.proxies || {}) as Record<string, ApiType.ProxyItem>;
} catch {
return {};
}
const instance = await getAxios();
const response = await instance.get<any, any>("/proxies");
return (response?.proxies || {}) as Record<string, ApiType.ProxyItem>;
}
/// Get the Proxy information
@ -151,24 +147,20 @@ export async function getProxies() {
// get proxy providers
export async function getProviders() {
try {
const instance = await getAxios();
const response = await instance.get<any, any>("/providers/proxies");
const instance = await getAxios();
const response = await instance.get<any, any>("/providers/proxies");
const providers = (response.providers || {}) as Record<
string,
ApiType.ProviderItem
>;
const providers = (response.providers || {}) as Record<
string,
ApiType.ProviderItem
>;
return Object.fromEntries(
Object.entries(providers).filter(([key, item]) => {
const type = item.vehicleType.toLowerCase();
return type === "http" || type === "file";
})
);
} catch {
return {};
}
return Object.fromEntries(
Object.entries(providers).filter(([key, item]) => {
const type = item.vehicleType.toLowerCase();
return type === "http" || type === "file";
})
);
}
// proxy providers health check