1 // This file is part of frontend-next <https://github.com/senpy-club/frontend-next>.
2 // Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, version 3.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // Copyright (C) 2022-2022 Fuwn <contact@fuwn.me>
17 // SPDX-License-Identifier: GPL-3.0-only
19 export const baseURL = "https://api.senpy.club";
20 export const baseAPI = `${baseURL}/v2`;
22 interface RandomImage {
27 export async function fetchImages(language: string): Promise<string[]> {
28 language = language.replace("#", "%23");
30 const response = await fetch(`${baseAPI}/language/${language}`);
32 return await response.json();
35 export async function fetchLanguages(): Promise<string[]> {
36 const response = await fetch(`${baseAPI}/languages`);
38 return await response.json();
41 export async function fetchRandomImage(): Promise<RandomImage> {
42 const response = await fetch(`${baseAPI}/random`);
44 return await response.json();