aswi2023one-team-to-rule-them-all-gitlab/src/stores/actions/homePageThunks.ts @ cbf81c55
1 | 4da7b143 | Schwobik | import { createAsyncThunk } from "@reduxjs/toolkit" |
---|---|---|---|
2 | import { fetchHomeDataRequest } from "../../api/homePageService" |
||
3 | import { HomePageData } from "../../types/homePageTypes" |
||
4 | |||
5 | export const fetchData = createAsyncThunk( |
||
6 | "homePage/fetchData", |
||
7 | async (_, thunkAPI) => { |
||
8 | const response = await fetchHomeDataRequest() |
||
9 | if (response.status !== 200) { |
||
10 | return thunkAPI.rejectWithValue("Failed to fetch data") |
||
11 | }
|
||
12 | return response.data as HomePageData |
||
13 | }
|
||
14 | )
|