Nuxt/docs/content/3.api/3.utils/clear-error.md
Ada J 48d886c860
docs(api): document useError , useLazyAsyncData and useLazyFetch (#4341)
* docs: add documents for use-error,use-lazy-async-data and use-lazy-fetch

* docs(API): document useError,useLazyAsyncData and useLazyFetch

Co-authored-by: xiaojie.jiang <xiaojie.jiang@dhc.com.cn>
2022-04-14 10:53:58 +02:00

690 B

clearError

Nuxt provides a composable to clear all handled errors.

Within your pages, components, and plugins, you can use clearError to clear all errors and redirect the user.

Parameters:

  • options?: { redirect?: string }

You can provide an optional path to redirect to (for example, if you want to navigate to a 'safe' page).

// Without redirect
clearError()

// With redirect
clearError({ redirect: '/homepage' })

Errors are set in state using useError(). The clearError composable will reset this state and calls the app:error:cleared hook with the provided options.

::ReadMore{link="/guide/features/error-handling"} ::