When I use fetch in React I got this error:
'Error: Objects are not valid as a React child (found: object with keys {results, info})'
This is my code:
import React from "react";
import "./App.css";
class App extends React.Component {
constructor() {
super();
this.state = {
data: [],
IsLoding: false,
};
}
componentDidMount() {
fetch("https://api.randomuser.me/")
.then(response => response.json())
.then(data => this.setState({
data: data,
IsLoding: true
}));[enter image description here][1]
}
render() {
return (
<div>
<h1>
Hello
{this.state.data}
</h1>
</div>
);
}
}
export default App;
the error [1]: https://i.stack.imgur.com/klKKP.jpg
When I try console.log(data)
it's working but when I try to get the data to page not working.