I’m trying to do an app that fetches data from an API. When I use my API, all the data are there:
API Data from DataBase
But when I’m trying to fetch all those data from my Next.js app, I get 2 different results:
-
The VS Code console result (only the 3 first row of my array):
VS Code console Result
-
And Chrome inpection tool result:
Chrome result
But I don’t know why on my app I can have access only at the 3 first row even if Chrome show all of them.
Function from page.js
:
export default async function Home() {
const data = await User();
console.log(data);
return (
<h1>Hello</h1>
)}
User function:
export default async function User() {
const res = await fetch('http://localhost:3001/getAllPlayers')
return res.json()
}
I already tried to modify my fetch function, but I don’t see a lot of problems like mine online.
Gormec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2