Redux中发送异步请求获取数据

1. charles模拟数据

先在桌面创建一个list.json的文件:

["hello","scott","xiong"]

然后用charles做接口转发

打开charles,选择 Tools/Map Local/Add, 然后配置如下:

2. 安装axios

yarn add axios

http请求放在componentDidMount()中:

完整的demo: https://github.com/scott-x/react-demo/tree/master/axios%E5%8F%91%E9%80%81%E5%BC%82%E6%AD%A5%E8%AF%B7%E6%B1%82