前端项目发送请求的方式
(1)jQuery—$.get 容易回调地狱
(2)axios----axios.get Promise风格
以上俩种需要xhr,没有xhr就不能发,本质上是ajax请求
(3)fetch:系统自带的,直接发送,不需要xhr,也是Promise风格
axios发送请求
search = async () =>{
const {
value} = this.keyWordNode
// http://api.github.com/search/users?q=xxxxx
// 发送请求前更新状态
this.props.updateAppState({
isFirst:false,isLoading: true})
PubSub.publish('msg',{
isFirst:false,isLoading: true})
axios