Complete the code to import the Next.js revalidation function.
import { [1] } from 'next/cache';
The revalidatePath function is imported from next/cache to trigger on-demand revalidation of a path.
Complete the code to trigger revalidation for the '/blog' path.
export async function POST() {
[1]('/blog');
return new Response('Revalidated');
}The revalidatePath function is called with the path string to refresh the cached page.
Fix the error in the code to correctly revalidate the '/products' page.
import { revalidatePath } from 'next/cache'; export async function POST() { await [1]('/products'); return new Response('Done'); }
The function revalidatePath is called with the path as argument. The await keyword is used correctly with the function call.
Fill both blanks to create a POST API route that revalidates '/dashboard' and returns a JSON response.
import { [1] } from 'next/cache'; export async function POST() { await [2]('/dashboard'); return new Response(JSON.stringify({ message: 'Revalidated' }), { headers: { 'Content-Type': 'application/json' } }); }
Both blanks require the revalidatePath function: one for import and one for calling it.
Fill all three blanks to create a server action that revalidates a dynamic path and returns a success message.
import { [1] } from 'next/cache'; export async function revalidatePage(slug) { await [2](`/posts/$[3]`); return 'Page revalidated'; }
The function revalidatePath is imported and called with the dynamic path using the slug variable.