Complete the code to fetch data at build time for static generation of dynamic routes in Next.js using the new App Router.
export async function [1]() { const res = await fetch('https://api.example.com/data'); return res.json(); }
In Next.js App Router, generateStaticParams is used for static generation with dynamic routes, which involves data fetching at build time.
Complete the code to fetch data with caching disabled in Next.js App Router.
const data = await fetch('https://api.example.com/data', { cache: [1] }).then(res => res.json());
Setting cache: 'no-store' disables caching and fetches fresh data on every request.
Complete the fetch call to ensure data is cached but revalidated every 60 seconds in Next.js App Router.
const data = await fetch('https://api.example.com/data', { next: { [1]: 60 } }).then(res => res.json());
The next: { revalidate: 60 } option sets Incremental Static Regeneration (ISR) to revalidate the cache every 60 seconds.
Fill both blanks to create a fetch call that caches data but revalidates every 30 seconds.
const data = await fetch('https://api.example.com/data', { cache: '[1]', next: { [2]: 30 } }).then(res => res.json());
Using cache: 'force-cache' enables caching, and next: { revalidate: 30 } sets ISR to refresh every 30 seconds.
Fill all three blanks to create a fetch call that uses POST, disables caching, and sets revalidation to 0.
const data = await fetch('https://api.example.com/data', { method: '[1]', cache: '[2]', next: { [3]: 0 } }).then(res => res.json());
method: 'POST' for mutations, cache: 'no-store' disables caching, next: { revalidate: 0 } ensures dynamic rendering with no stale data.