export async function generateStaticParams() { const posts = await…
- User
export async function generateStaticParams() { const posts = await fetch('https://.../posts').then((res) => res.json())
// Render the first 10 posts at build time return posts.slice(0, 10).map((post) => ({ slug: post.slug, })) } explain the code
Assistant
This is a Next.js function that generates static parameters for dynamic routes at build time. Here's how it works:
The function fetches data from an API endpoint that returns a list of posts. It makes an HTTP request to
https://.../postsand converts the response to JSON format.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.