Skip to content

Commit

Permalink
docs(routing): update params type to be async (v15) (vercel#73111)
Browse files Browse the repository at this point in the history
## Why?

Update params type to be async (v15).

- x-ref: vercel#72070
  • Loading branch information
samcx authored Nov 22, 2024
1 parent 37b815b commit 915efdd
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ async function fetchTeam(id: string) {
return res.json()
}

export default async function Profile({ params }: { params: { id: string } }) {
const team = await fetchTeam(params.id)
if (!team) {
export default async function Profile({
params,
}: {
params: Promise<{ id: string }>
}) {
const id = (await params).id
if (!id) {
redirect('/login')
}

const team = await fetchTeam(id)
if (!team) {
redirect('/join')
}

// ...
}
```
Expand All @@ -97,11 +106,16 @@ async function fetchTeam(id) {
}

export default async function Profile({ params }) {
const team = await fetchTeam(params.id)
if (!team) {
const id = (await params).id
if (!id) {
redirect('/login')
}

const team = await fetchTeam(id)
if (!team) {
redirect('/join')
}

// ...
}
```
Expand Down

0 comments on commit 915efdd

Please sign in to comment.