Having done the necessary to read the data using fetchAPI, I am having problems displaying the content because of the nature of the array.
import React, { useState, useEffect } from "react";
function Home() {
const [userData, setUserData] = useState([]);
async function getData() {
let response = await fetch("https://api.xxxxxxxx.io/something/students");
let data = await response.json();
return data;
}
//call getData function
getData().then((data) => console.log(data)); //
useEffect(() => {
getData()
.then((data) => {
setUserData(data);
})
.catch((error) => {
console.log(error);
});
}, []);
return (
<div>
{Object.keys(userData).map((item, index) => (
<div key={index}>{item}</div>
))}
</div>
);
}
export default Home;
When I checked the console, the data are displayed but it is only showing students with no other data displayed. I have the data below.

Object.keys(userData)will give you back["students"]. If you want to display all student objects then douserData.students.map(student => ...)and access the student properties you want to show.useEffect? for the Promise resolution? AuseEffectwithout a dependency runs every rerender anyway. Also, you canuserData.students.map(({email}) => <p>{email}</p>)Edit: Remove the dependency array because, you are calling thegetDatafunction outsideuseEffectalso right.<div>at the very least.studentsproperty. Maybe you wantsetUserData(data.students);anduserData.map(...)instead.