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 }); };}
1 回答

UYOU
TA贡献1878条经验 获得超4个赞
但是你这样写还是需要的,redux-thunk就是支持Function Action。
这种你想在ActionCreator 中自己dispatch,还是要用这种方法。
如果你的Action诗歌Promise,你可以换成 redux-promise,他会自动帮你dispatch resolve后的值。
添加回答
举报
0/150
提交
取消