在react中利用redux和fetch獲取數據并渲染到頁面?
1 回答

陪伴而非守候
TA貢獻1757條經驗 獲得超8個贊
actions:
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 回答
- 0 關注
- 1608 瀏覽
添加回答
舉報
0/150
提交
取消