以下のコードは、reduxアプリケーション設計でPOSTリクエストを提供するための正しいアプローチですか?Redux POSTアクションを提供する方法
コードは問題ありませんが、何らかの理由でアーキテクチャが再構築されているかどうかはわかりません。
export const SITES_RECEIVED = 'SITES_RECEIVED';
//@private
function sitesReceived(sites) {
return {
type: SITES_RECEIVED,
sites: sites
};
}
//@public
export const sitesFetch =() => {
return dispatch => {
fetch('http://localhost:3000/')
.then(function(response) {
return response.text();
}).then(function(body) {
return JSON.parse(body);
}).then(function(json) {
dispatch(sitesReceived(json));
})
};
}
要件:Reduxの、
これは可能な方法です。あなたのアプローチは大丈夫です。 – Florent