I'm attempting to pull data from the array below. My code is below my console.log. What am I doing wrong? Nothing is rendering when I attempt to pull the data.
(356) […]
[0…99]
0: Object { TournamentID: 405, Name: "The Presidents Cup", StartDate: "2021-09-30T00:00:00", … }
1: Object { TournamentID: 453, Name: "Tour Championship", StartDate: "2021-09-02T00:00:00", … }
2: Object { TournamentID: 452, Name: "BMW Championship", StartDate: "2021-08-26T00:00:00", … }
Below is the code I'm using to pull the data.
function App() {
const [data, setData] = useState([])
useEffect(()=>{
axios
.get('https://api.sportsdata.io/golf/v2/json/Tournaments?key=72259e02756442d38c6b837dd8625e4f')
.then((res)=> {
console.log(res.data)
setData(res.data)
})
},[])
return (
<div className="App">
<div className='container'>
<h1>{data.Name}</h1>
</div>
</div>
);
}
export default App;