mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-06 06:52:07 +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 {
|
||||
urlTest(
|
||||
async urlTest(
|
||||
protocol: string,
|
||||
url: string,
|
||||
params?: any
|
||||
): Promise<UrlTestResponse> {
|
||||
return new Promise<UrlTestResponse>((resolve, reject) => {
|
||||
apis.axios
|
||||
.get(`../test/${protocol}/${url}api/system/status`, { params })
|
||||
.then((result) => resolve(result.data))
|
||||
.catch(reject);
|
||||
});
|
||||
try {
|
||||
const result = await apis.axios.get<UrlTestResponse>(
|
||||
`../test/${protocol}/${url}api/system/status`,
|
||||
{ params }
|
||||
);
|
||||
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