You need to go to the array portion of the api reponse (records), otherwise the data wil be an object ({}) which you cannot use .map on. the data.records.profiles will be an array ([]) and that will work with a .map function.
change you code to
useEffect(() => {
const fetchRecords = async () => {
setLoading(true)
const res = await fetch('http://api.enye.tech/v1/challenge/records')
const data = await res.json();
setRecords(data.records.profiles)
setLoading(false)
}
fetchRecords()
// eslint-disable-next-line
}, [])
also check that the records are not loading
{!loading ? <Records records={records} /> : <></>}
You might also want to change the state name to 'profiles' and not records because you are only using the profiles portion on the reponse
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…