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.
Fetch data from Strapi and process it - Next.js Tutorial
From the course: The Freelance Stack: Real Project with Next.js and Strapi
Fetch data from Strapi and process it
We stopped at the moment where we saw we can actually bring the data in right here. That's our data. Now I already mentioned that we are going to fetch data all over the place, so it makes sense for us to put this kind of logic into an extra utility function. So what we're going to be doing is we're actually going to create a new folder outside of the app directory. We're going to say in the root folder a utils folder and we're going to call, we're going to create one function, one file called strappy utils.js. You don't have to do the .utils but I always like it when I look through Visual Studio Code that I immediately find what I'm looking for. Now what I want to do here is actually just handle or do everything that is regarding the data fetching and data handling. So this step here already I want to do in my utils file. The first thing I was going to do is actually create our base URL. This is our Strapi URL and it will be depending on whether we are deployed or not, like whether…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Creating InfoBlock content type on Strapi14m 57s
-
(Locked)
Use single content type in Strapi to create InfoBlocks per page17m 33s
-
(Locked)
Fetch InfoBlock data on Strapi8m 27s
-
(Locked)
Fetch data from Strapi and process it16m 57s
-
(Locked)
Render InfoBlocks on page9m 20s
-
(Locked)
Create button from InfoBlock Strapi data on page7m 13s
-
(Locked)
Render InfoBlocks on experience page4m 45s
-
(Locked)
-
-
-
-
-