/
anv
/
hackathon
Обзор
Документация
Войти
/
anv
/
hackathon
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/requests/getChatById.tsx
29 строк
769 B
ANV
enabled backend
25 мар 2025, 00:43
25 мар 2025, 00:43
cb2ad90
Код
Авторство
О чём код?
/* eslint-disable camelcase */ import {RawMessages} from '@/components/types'; import {API_PATH} from '../constants'; import axios from 'axios'; type Props = { chat_id: string; user_id: string; }; type GetResponse = RawMessages & { status: string; }; export const getChatById = ({user_id, chat_id}: Props): Promise<GetResponse> => { const apiUrl = `${API_PATH}chats/${chat_id}?user_id=${user_id}`; return axios .get(apiUrl) .then((resp) => { const {messages, preview_text, id} = resp.data; return {status: 'ok', messages, id, preview_text}; }) .catch((e) => { console.error(e); return {status: 'error', id: chat_id, messages: [], preview_text: ''}; }); };