From the course: The Freelance Stack: Real Project with Next.js and Strapi

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Data fetching

Data fetching

So now that we talked about server and client components we can start talking about data fetching in Next.js because the ability to have data attached to a certain component actually makes it incredibly easy for us to now fetch data without having to create our own API routes or anything like that. We can now fetch data directly from the component even if we are using API keys or other secrets or things like that. That's another huge advantage of server components. So let's say on our blog page we want to have some kind of article displayed and I'm going to use a free open API later on during the course. Obviously we will be using our Strapi API. So let me bring this over here. This is the API that we're using which is really cool because it just gives you some data to test your logic with. Now we're going to be looking at the posts here. So this is going to be our URL and I have a browser plug-in here that makes it nicely formatted. Overall there's a hundred posts that we can fetch…

Contents