diff --git a/docs/01-app/02-building-your-application/02-data-fetching/01-fetching.mdx b/docs/01-app/02-building-your-application/02-data-fetching/01-fetching.mdx index e29531d80c1b8..d70ee42a0565e 100644 --- a/docs/01-app/02-building-your-application/02-data-fetching/01-fetching.mdx +++ b/docs/01-app/02-building-your-application/02-data-fetching/01-fetching.mdx @@ -271,7 +271,7 @@ If you are using `fetch`, requests can be [memoized](/docs/app/building-your-app > > - In previous versions of Next.js, using `fetch` would have a default `cache` value of `force-cache`. This changed in version 15, to a default of `cache: no-store`. -```tsx filename="app/page.tsx" switcher +```tsx filename="app/blog/[id]/page.tsx" switcher import { notFound } from 'next/navigation' interface Post { @@ -295,7 +295,7 @@ export async function generateStaticParams() { }).then((res) => res.json()) return posts.map((post: Post) => ({ - id: post.id, + id: String(post.id), })) } @@ -304,7 +304,8 @@ export async function generateMetadata({ }: { params: Promise<{ id: string }> }) { - let post = await getPost(params.id) + const { id } = await params + let post = await getPost(id) return { title: post.title, @@ -316,7 +317,8 @@ export default async function Page({ }: { params: Promise<{ id: string }> }) { - let post = await getPost(params.id) + const { id } = await params + let post = await getPost(id) return (
@@ -327,7 +329,7 @@ export default async function Page({ } ``` -```jsx filename="app/page.js" switcher +```jsx filename="app/blog/[id]/page.js" switcher import { notFound } from 'next/navigation' async function getPost(id) { @@ -343,12 +345,13 @@ export async function generateStaticParams() { ) return posts.map((post) => ({ - id: post.id, + id: String(post.id), })) } export async function generateMetadata({ params }) { - let post = await getPost(params.id) + const { id } = await params + let post = await getPost(id) return { title: post.title, @@ -356,7 +359,8 @@ export async function generateMetadata({ params }) { } export default async function Page({ params }) { - let post = await getPost(params.id) + const { id } = await params + let post = await getPost(id) return (