Запрос fetchHomeMainFx возвращает нужный response ( консолила ), но при этом $homePage всегда null, в чем ошибка в записи?
import { createEffect, createEvent, restore } from 'effector';
// ~~ Events ~~ //
export const fetchHomePage = createEvent('fetch-home-page');
export const fetchHomeMain = createEvent('fetch-home-page-main');
// ~~ Effects ~~ //
export const fetchHomeMainFx = createEffect(async () => {
const response = await fetch('api/home/', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
news_limits: {
videoReviews: 1,
marketReviews: 5,
comments: 4,
stocksNews: 5,
IPONews: 3,
innovationStocks: 5
}
})
})
.then((data) => data.json())
.then((data) => data);
return response;
});
// ~~ Stores ~~ //
export const $homePage = restore<WithStatus<HomePage>>(fetchHomeMainFx, null);
forward({
from: fetchHomePage,
to: [fetchLayout, fetchHomeMain]
});
forward({
from: fetchHomeMain,
to: fetchHomeMainFx
});
const Home: NextPage = () => {
const homePage = useStore($homePage);
useEffect(() => {
fetchHomePage();
}, []);