From the course: Learning Next.js
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Using dynamic routes and user's input to query content
From the course: Learning Next.js
Using dynamic routes and user's input to query content
- [Instructor] Now we continue with the demonstration of getServerSideProps here with this dynamic route. There's just one thing I'd like to show you. So before we actually get to the part where we need to make an API call from the New York Times API again. So you're going to notice that we are using here a handler. So I decided to move this function which is to make the API call in a separate module, because it's always good practice to never make any API call in a React component. So I decided to move it here in this location. And the other benefit is that, this is reusable helper function this time. So you can use it wherever and whenever you'd like. And so that's always good practice to separate concerns. So now you've got this handler that you can use. So this is cleaner. And we're going to do the same here in query. We're going to use the search. So we're going to get a response back by using this search…
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
-
-
-
-
-
Discovering the rendering strategies3m 51s
-
(Locked)
Discovering the rendering strategies with getStaticProps4m 17s
-
(Locked)
Pre-rendering at build time with static generation4m 32s
-
(Locked)
Pre-rendering super fast and super SEO-efficient content3m 17s
-
(Locked)
Discovering the rendering strategies with getServerSideProps4m 15s
-
(Locked)
Using dynamic routes and user's input to query content3m 51s
-
(Locked)
Search, request, and pre-render content with SSR2m 18s
-
(Locked)
Discovering the rendering strategies with getStaticPaths3m 47s
-
(Locked)
Pre-rendering at build time with static paths5m 9s
-
(Locked)
Handling errors with a fallback page (404 not found)2m 59s
-
(Locked)
Customizing an error page2m 16s
-
(Locked)
Challenge: Pre-rendering at build vs. runtime4m 25s
-
(Locked)
Solution: Pre-rendering at build vs. runtime8m 57s
-
-
-