当我想发送一个请求时,直接在fetch函数里写不就好了么,为什么要多一步中间件呢?const mapDispatchToProps = ( dispatch )=>({ fetchAndRenderArticle( articleName ){ fetch(`http://localhost:3000/getFile?articleName=${articleName}`).then( res=> { return res.text(); }).then( articleContent =>{ dispatch({ type:'fetchAndRenderArticle', articleContent:articleContent }); }).catch( err=>{ console.log(err); }); }});
添加回答
举报
0/150
提交
取消
