diff --git a/frontend/src/apis/utils.ts b/frontend/src/apis/utils.ts index 9601a692b..f45b53150 100644 --- a/frontend/src/apis/utils.ts +++ b/frontend/src/apis/utils.ts @@ -11,17 +11,29 @@ type UrlTestResponse = }; class RequestUtils { - urlTest( + async urlTest( protocol: string, url: string, params?: any ): Promise { - return new Promise((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( + `../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( + `../test/${protocol}/${url}api/v3/system/status`, + { params } + ); + return result.data; + } } }