/
WorldOfYuri
/
react-1
Обзор
Документация
Войти
/
WorldOfYuri
/
react-1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/api/profile-api.ts
42 строки
1 KB
Юрий Кузмичев
add ts in files
18 июл 2023, 15:21
18 июл 2023, 15:21
2516144
Код
Авторство
О чём код?
import { PhotosType, ProfileType } from "../types/types"; import { APIResponseType, instance } from "./api"; type SavePhotoResponseDataType = { photos: PhotosType; }; export const profileAPI = { getProfile(userId: number) { return instance.get<ProfileType>(`profile/${userId}`).then(res => res.data); }, getStatus(userId: number) { return instance .get<string>(`profile/status/${userId}`) .then(res => res.data); }, updateStatus(status: string) { return instance .put<APIResponseType>(`profile/status/`, { status }) .then(res => res.data); }, savePhoto(photoFile: File) { const formData = new FormData(); formData.append("image", photoFile); return instance .put<APIResponseType<SavePhotoResponseDataType>>( `profile/photo/`, formData, { headers: { "Content-Type": "multipart/form-data", }, } ) .then(res => res.data); }, saveProfile(profile: ProfileType) { return instance .put<APIResponseType>(`profile/`, profile) .then(res => res.data); }, };