Skip to content

Commit

Permalink
add link instead of code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
mert-duzgun authored Jul 7, 2024
1 parent 9975252 commit 4e3c168
Showing 1 changed file with 1 addition and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ You could also use the returned state to display a toast message from the client
### Handling Expected Errors from Server Components
When fetching data inside of a Server Component, you can use the response to conditionally render an error message or `redirect`.
When fetching data inside of a Server Component, you can use the response to conditionally render an error message or [`redirect`](/docs/app/building-your-application/routing/redirecting#redirect-function).
```tsx filename="app/page.tsx" switcher
export default async function Page() {
Expand Down Expand Up @@ -137,37 +137,6 @@ export default async function Page() {
}
```
Or
```tsx filename="app/page.tsx" switcher
import { redirect } from 'next/navigation'

export default async function Page() {
const res = await fetch(`https://...`)
const data = await res.json()

if (!res.ok) {
redirect("/dashboard")
}

return '...'
}
```
```jsx filename="app/page.js" switcher
import { redirect } from 'next/navigation'

export default async function Page() {
const res = await fetch(`https://...`)
const data = await res.json()

if (!res.ok) {
redirect('/dashboard')
}

return '...'
}
```
## Uncaught Exceptions
Uncaught exceptions are unexpected errors that indicate bugs or issues that should not occur during the normal flow of your application. These should be handled by throwing errors, which will then be caught by error boundaries.
Expand Down

0 comments on commit 4e3c168

Please # to comment.