【发布时间】:2023-03-13 15:01:01
【问题描述】:
class Rnn extends Component{
constructor(props){
super(props);
this.state={
x:[]
}
}
componentWillMount(){
var api={
getroverss(){
var url="https://fcctop100.herokuapp.com/api/fccusers/top/recent";
return fetch(url).then((res) => res.json());
}
},
api.getrovers().then((res) =>{
this.setState({ x: res
})
});
}
render(){
var xx=this.state.x;
console.table(xx);
return (
<h1>print data</h1>
);
}}
我一直在使用这个 api 从中获取数据。我已经设法在控制台上输出数据。如何获取(输出/打印)我网页上的数据? (我只想使用 fetch 方法)。
【问题讨论】:
标签: reactjs