From 697f55d1200bb2321f0e438edf2fc6e6820f661f Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Sat, 23 Nov 2024 16:16:45 -0500 Subject: [PATCH] Copy FetchBaseQueryError type into docs --- docs/rtk-query/api/fetchBaseQuery.mdx | 54 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/docs/rtk-query/api/fetchBaseQuery.mdx b/docs/rtk-query/api/fetchBaseQuery.mdx index 456ab0dc18..8f88b444ce 100644 --- a/docs/rtk-query/api/fetchBaseQuery.mdx +++ b/docs/rtk-query/api/fetchBaseQuery.mdx @@ -83,14 +83,60 @@ type FetchBaseQueryResult = Promise< meta?: { request: Request; response: Response } } | { - error: { - status: number - data: any - } + error: FetchBaseQueryError data?: undefined meta?: { request: Request; response: Response } } > + +type FetchBaseQueryError = + | { + /** + * * `number`: + * HTTP status code + */ + status: number + data: unknown + } + | { + /** + * * `"FETCH_ERROR"`: + * An error that occurred during execution of `fetch` or the `fetchFn` callback option + **/ + status: 'FETCH_ERROR' + data?: undefined + error: string + } + | { + /** + * * `"PARSING_ERROR"`: + * An error happened during parsing. + * Most likely a non-JSON-response was returned with the default `responseHandler` "JSON", + * or an error occurred while executing a custom `responseHandler`. + **/ + status: 'PARSING_ERROR' + originalStatus: number + data: string + error: string + } + | { + /** + * * `"TIMEOUT_ERROR"`: + * Request timed out + **/ + status: 'TIMEOUT_ERROR' + data?: undefined + error: string + } + | { + /** + * * `"CUSTOM_ERROR"`: + * A custom error type that you can return from your `queryFn` where another error might not make sense. + **/ + status: 'CUSTOM_ERROR' + data?: unknown + error: string + } ``` ## Parameters