export const getMenu = () => {
return async (dispatch) => {
let msg = await fetch('data/nodes',{
method: 'POST',
//body: JSON.stringify({"aa":"aa"}),
header: {'content-type':'application/json; charset=utf-8'}
}).then((res)=>res.json());
var state = { nodes: msg };
dispatch({
type: 'INIT',
state
});
};
}
但是你这样写还是需要的,redux-thunk就是支持Function Action。
这种你想在ActionCreator 中自己dispatch,还是要用这种方法。
如果你的Action诗歌Promise,你可以换成 redux-promise,他会自动帮你dispatch resolve后的值。