下面的代碼是否正確地在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));
})
};
}
要求:終極版,終極版 - 咚
這是一種可行的方法。你的方法很好。 – Florent