2024-03-28 11:43:24 +00:00
|
|
|
import { BotApiResponse } from "../types/BotApiResponse";
|
|
|
|
|
|
|
|
class BotApiService {
|
2024-04-15 08:54:01 +00:00
|
|
|
readonly BOT_API_URL = "http://192.168.178.27:30000";
|
2024-03-28 11:43:24 +00:00
|
|
|
|
|
|
|
async getAll(): Promise<BotApiResponse> {
|
|
|
|
const get_url = `${this.BOT_API_URL}/images`;
|
|
|
|
const response: BotApiResponse = await fetch(get_url)
|
|
|
|
.then(res => {
|
|
|
|
if (!res.ok) {
|
|
|
|
throw new Error("Error fetching images");
|
|
|
|
} else {
|
2024-04-15 08:54:01 +00:00
|
|
|
return res.json();
|
2024-03-28 11:43:24 +00:00
|
|
|
}
|
|
|
|
}) as BotApiResponse;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default new BotApiService();
|