0
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从它获取数据。我已经设法输出控制台上的数据。如何获取(输出/打印)我网页上的数据? (我只想使用提取方法)。使用ReactJs从页面上输出API数据
我应该在哪里添加这些回报声明? –
@sugandhgoyal正确! – Rowland
它在行 - api.getrovers处给出错误。 –