/
WorldOfYuri
/
react-1
Обзор
Документация
Войти
/
WorldOfYuri
/
react-1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/api/auth-api.ts
39 строк
879 B
Юрий Кузмичев
add ts in files
18 июл 2023, 15:21
18 июл 2023, 15:21
2516144
Код
Авторство
О чём код?
import { APIResponseType, ResultCodeEnum, ResultCodeEnumForCaptcha, instance, } from "./api"; type MeResponseDataType = { id: number; email: string; login: string }; type LoginResponseDataType = { userId: number }; export const authAPI = { me() { return instance .get<APIResponseType<MeResponseDataType>>(`auth/me`) .then(res => res.data); }, login( email: string, password: string, rememberMe = false, captcha: null | string = null ) { return instance .post< APIResponseType< LoginResponseDataType, ResultCodeEnum | ResultCodeEnumForCaptcha > >(`auth/login`, { email, password, rememberMe, captcha, }) .then(res => res.data); }, logout() { return instance.delete(`auth/login`); }, };