我使用 FETCH 从 TMDB API 上传了我的数据,当我尝试通过它进行映射时,它给了我一个错误 undefined is not an object(评估“NowMovies.map”)
这是我的代码:
constructor(props){
super(props);
this.state={
NowMovies:[],
isLoaded:false
}
}
componentDidMount(){
fetch('API')
.then(data => data.json())
.then(({MoviesLists}) => {this.setState({
isLoaded:true,
NowMovies:MoviesLists
})
})
}
render(){
var {isLoaded,NowMovies} = this.state
if (!isLoaded){
return <div> .... Loading</div>
}
else{
return(
<div>
<ul>
{NowMovies.map(Movie=>(<li key={NowMovies.id}> name:{NowMovies.original_title}</li>
))}
</ul>
</div>
谁能帮我将这些数据加载到我的数组中并通过它映射?
holdtom
子衿沉夜
相关分类