feat(web-app): add verification available connection to backend for the http client

This commit is contained in:
fastium
2025-05-06 16:22:23 +02:00
parent e18bed5fbc
commit d6e3a5c1e0

View File

@@ -0,0 +1,31 @@
import axios from "axios";
const BASE = "https://";
const PING = "ping";
const RACLETTE = "raclette";
const PONG = "pong";
export class HttpClient {
private _url: string;
constructor(url: string) {
this._url = url;
}
async isConnected(): Promise<boolean> {
var connected = false;
if (await this.ping()) {
connected = true;
console.log("Connected to backend!");
} else {
connected = false;
console.log("Connection failed backend!");
}
return connected;
}
private async ping(): Promise<string> {
const response = await axios.get(`${BASE}${this._url}/${PING}`);
return response.data;
}
}