21 lines
589 B
TypeScript
21 lines
589 B
TypeScript
|
import { BotApiResponse } from "../types/BotApiResponse";
|
||
|
|
||
|
class BotApiService {
|
||
|
readonly BOT_API_URL = "piparadis:30000";
|
||
|
|
||
|
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 {
|
||
|
res.json();
|
||
|
}
|
||
|
}) as BotApiResponse;
|
||
|
return response;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
export default new BotApiService();
|