[英]cant access Api response in react js
I cant access data object in the red circle (see image) but I can access it outside , please help as I cant understand what I am doing wrong?我无法访问红色圆圈中的数据对象(见图),但我可以在外面访问它,请帮忙,因为我不明白我做错了什么?
A simple example of a class component with state具有状态的类组件的简单示例
export default class extends React.Component {
constructor() { this.state = {data:[]}; }
componentDidMount() {
//Fetch data
getTrendingVideo.then() { res => this.setState({data: res})}
}
render() {
console.log(this.state.data)
}
}
Is your browser debugging tool reporting an error?您的浏览器调试工具是否报告错误? It seems that the current class component does not define 'data'
似乎当前的类组件没有定义“数据”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.