refactor: update ping api to use new PingResponse

This commit is contained in:
Derrick Hammer 2024-03-13 17:30:03 -04:00
parent 6f1d761c99
commit 42751d5214
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import {
OTPValidateRequest, OTPValidateRequest,
OTPVerifyRequest, OTPVerifyRequest,
PasswordResetVerifyRequest, PasswordResetVerifyRequest,
PingResponse,
postApiAuthPasswordResetRequest, postApiAuthPasswordResetRequest,
postApiAuthPing, postApiAuthPing,
RegisterRequest, RegisterRequest,
@ -166,7 +167,14 @@ export default class AccountApi {
} }
public async ping(): Promise<boolean> { public async ping(): Promise<boolean> {
return this.checkSuccessBool(await postApiAuthPing(this.buildOptions())); let ret: AxiosResponse<PingResponse>;
try {
ret = await postApiAuthPing(this.buildOptions());
} catch (e) {
return false;
}
return this.checkSuccessVal(ret) && ret.data.ping == "pong";
} }
private checkSuccessBool(ret: AxiosResponse<void>): boolean { private checkSuccessBool(ret: AxiosResponse<void>): boolean {