Skip to content

Commit 697f55d

Browse files
committed
Copy FetchBaseQueryError type into docs
1 parent fe2d181 commit 697f55d

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

docs/rtk-query/api/fetchBaseQuery.mdx

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,60 @@ type FetchBaseQueryResult = Promise<
8383
meta?: { request: Request; response: Response }
8484
}
8585
| {
86-
error: {
87-
status: number
88-
data: any
89-
}
86+
error: FetchBaseQueryError
9087
data?: undefined
9188
meta?: { request: Request; response: Response }
9289
}
9390
>
91+
92+
type FetchBaseQueryError =
93+
| {
94+
/**
95+
* * `number`:
96+
* HTTP status code
97+
*/
98+
status: number
99+
data: unknown
100+
}
101+
| {
102+
/**
103+
* * `"FETCH_ERROR"`:
104+
* An error that occurred during execution of `fetch` or the `fetchFn` callback option
105+
**/
106+
status: 'FETCH_ERROR'
107+
data?: undefined
108+
error: string
109+
}
110+
| {
111+
/**
112+
* * `"PARSING_ERROR"`:
113+
* An error happened during parsing.
114+
* Most likely a non-JSON-response was returned with the default `responseHandler` "JSON",
115+
* or an error occurred while executing a custom `responseHandler`.
116+
**/
117+
status: 'PARSING_ERROR'
118+
originalStatus: number
119+
data: string
120+
error: string
121+
}
122+
| {
123+
/**
124+
* * `"TIMEOUT_ERROR"`:
125+
* Request timed out
126+
**/
127+
status: 'TIMEOUT_ERROR'
128+
data?: undefined
129+
error: string
130+
}
131+
| {
132+
/**
133+
* * `"CUSTOM_ERROR"`:
134+
* A custom error type that you can return from your `queryFn` where another error might not make sense.
135+
**/
136+
status: 'CUSTOM_ERROR'
137+
data?: unknown
138+
error: string
139+
}
94140
```
95141
96142
## Parameters

0 commit comments

Comments
 (0)