From the course: Learning Next.js

Unlock the full course today

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

Pre-rendering at build time with static generation

Pre-rendering at build time with static generation

From the course: Learning Next.js

Pre-rendering at build time with static generation

- So let's complete the demonstration with the function getStaticProps. And I'm going to start by getting what I need before I can ever pass any data to these props. I'd like to fetch data from the New York Times API, using this API key. So we're going to head to the documentations for the New York Times API and find what we need. So basically it's very simple, we're going to head here APIs, there's a list. There have multiple APIs available for free and we're going to get this one which is top stories. And remember that's in your case. So I am providing here this API key but I don't want this to be saturated. And the case several users use it at the same time, remember that there's always a limitation for anything free. So we're going into top stories API and we're going to get this example for an API call, this one. We're going to get the home example so this is just for the homepage. And so we're going to get a…

Contents