TypeError:------不是一个函数(在'.... this.state.dataSource ...附近)React Native API FETCH问题

时间:2019-04-26 10:34:49

标签: reactjs api datasource native typeerror

我正在通过本机学习 API 。 我想使用OMDB API。我有一些工作,我可以看到它从提取中收集数据,但是由于某种原因(我不知道),它返回了一个错误。

这是我获取数据的代码:

  componentDidMount(){
    let _imdbid = "tt3896198";
    return fetch('http://www.omdbapi.com/?i='+_imdbid+'&apikey=-------') // Middle is IMDB id
    .then((response) => response.json())
    .then((responseJson) => {
      this.setState({
        loading: false,
        dataSource: responseJson.Actors,
      })
    })
  }

错误:

  

TypeError:“克里斯·普拉特(Chris Pratt),佐伊·索尔达娜(Zoe Saldana),戴夫·包蒂斯塔(Dave Bautista),文·迪塞尔(Vin Diesel)”不是函数(在'... this.state.dataSource ...附近)

我在做什么错了?

0 个答案:

没有答案