/
bomjkee
/
hackathon-mini-app
Обзор
Документация
Войти
/
bomjkee
/
hackathon-mini-app
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/api/hackathons.ts
25 строк
901 B
bomjkee
first commit
22 фев 2025, 23:54
22 фев 2025, 23:54
bf0b735
Код
Авторство
О чём код?
import { type Hackathon, type HackathonList, HackathonListSchema, HackathonSchema } from "../types/hackathon"; import { createAPI } from "./api"; const api = createAPI(); export const getHackathonList = async (): Promise<HackathonList> => { try { const response = await api.get<HackathonList>('/hackathons'); return HackathonListSchema.parse(response.data) } catch (error) { console.error(`Ошибка при получении списка хакатонов: ${error}`); throw error; } }; export const getHackathon = async (id: number): Promise<Hackathon> => { try { const response = await api.get<Hackathon>(`/hackathons/${id}`); return HackathonSchema.parse(response.data); } catch (error) { console.error(`Ошибка при получении хакатона с ID ${id}:`, error); throw error; } };