/
dedaMazai
/
TestServer
Обзор
Документация
Войти
/
dedaMazai
/
TestServer
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/features/editableProfileCard/model/services/fetchProfileData/fetchProfileData.ts
24 строки
659 B
Andrey Chipizubov
fix
23 апр 2023, 17:32
23 апр 2023, 17:32
cc424e9
Код
Авторство
О чём код?
import { createAsyncThunk } from '@reduxjs/toolkit'; import { ThunkConfig } from '@/app/providers/StoreProvider'; import { Profile } from '@/entities/Profile'; export const fetchProfileData = createAsyncThunk< Profile, string, ThunkConfig<string> >('profile/fetchProfileData', async (profileId, thunkApi) => { const { extra, rejectWithValue } = thunkApi; try { const response = await extra.api.get<Profile>(`/profile/${profileId}`); if (!response.data) { throw new Error(); } return response.data; } catch (e) { console.log(e); return rejectWithValue('error'); } });