我是靠谱客的博主 满意玉米,这篇文章主要介绍React请求数据,现在分享给大家,希望可以做个参考。

在这里插入代码片
```// 请求
  requestData = (jgbh, ksnd, jsnd, page) => {
    console.log('请求数据', jgbh, jsnd, jsnd, page)
    fetch(firstGradeQuery, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        jgbh, ksnd, jsnd, page, size: 10
      })
    }).then(res => {
      if (res.ok) {
        return res.json()
      }
      throw new Error(res.status)
    }, rej => console.log(rej))
      .then(data => {
        console.log('返回数据', data)
        const ary = data.results || []

        this.setState({
          total: data.totalcount,
          dataSource: ary.map((item, index) => {
            return { ...item, index }
          }),
          currentPage: page
        })
      })
      .catch(err => errorTip(err.message))
  }
//注释:firstGradeQuery是查询接口。

最后

以上就是满意玉米最近收集整理的关于React请求数据的全部内容,更多相关React请求数据内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部