next.js/test/e2e/app-dir/use-cache-route-handler-only/app/node/route.ts
route.ts22 lines437 B
import { setTimeout } from 'timers/promises'

async function getCachedDate() {
  'use cache'

  // Simulate I/O latency.
  await setTimeout(200)

  return new Date().toISOString()
}

export async function GET() {
  const date1 = await getCachedDate()
  const date2 = await getCachedDate()

  const response = JSON.stringify({ date1, date2 })

  return new Response(response, {
    headers: { 'content-type': 'application/json' },
  })
}
Quest for Codev2.0.0
/
SIGN IN