mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-23 15:17:40 +08:00
Fix some incompatible calls in URL test button
This commit is contained in:
parent
e9ef40c629
commit
7687013270
1 changed files with 19 additions and 7 deletions
|
@ -11,17 +11,29 @@ type UrlTestResponse =
|
||||||
};
|
};
|
||||||
|
|
||||||
class RequestUtils {
|
class RequestUtils {
|
||||||
urlTest(
|
async urlTest(
|
||||||
protocol: string,
|
protocol: string,
|
||||||
url: string,
|
url: string,
|
||||||
params?: any
|
params?: any
|
||||||
): Promise<UrlTestResponse> {
|
): Promise<UrlTestResponse> {
|
||||||
return new Promise<UrlTestResponse>((resolve, reject) => {
|
try {
|
||||||
apis.axios
|
const result = await apis.axios.get<UrlTestResponse>(
|
||||||
.get(`../test/${protocol}/${url}api/system/status`, { params })
|
`../test/${protocol}/${url}api/system/status`,
|
||||||
.then((result) => resolve(result.data))
|
{ params }
|
||||||
.catch(reject);
|
);
|
||||||
});
|
const { data } = result;
|
||||||
|
if (data.status && data.version) {
|
||||||
|
return data;
|
||||||
|
} else {
|
||||||
|
throw new Error("Cannot get response, fallback to v3 api");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
const result = await apis.axios.get<UrlTestResponse>(
|
||||||
|
`../test/${protocol}/${url}api/v3/system/status`,
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue