File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ export interface Config<T extends ClientOptions = ClientOptions>
39
39
* @default globalThis.fetch
40
40
*/
41
41
fetch ?: typeof fetch ;
42
+ /**
43
+ * Controls the native ofetch behaviour that throws `FetchError` when
44
+ * `response.ok === false`. We default to suppressing it to match the fetch
45
+ * client semantics and let `throwOnError` drive the outcome.
46
+ */
47
+ ignoreResponseError ?: OfetchOptions [ 'ignoreResponseError' ] ;
42
48
// No custom fetch option: provide custom instance via `ofetch` instead
43
49
/**
44
50
* Please don't use the Fetch client for Next.js applications. The `next`
Original file line number Diff line number Diff line change @@ -322,6 +322,9 @@ export const buildOfetchOptions = (
322
322
body,
323
323
dispatcher : opts . dispatcher as OfetchOptions [ 'dispatcher' ] ,
324
324
headers : opts . headers as Headers ,
325
+ ignoreResponseError :
326
+ ( opts . ignoreResponseError as OfetchOptions [ 'ignoreResponseError' ] ) ??
327
+ true ,
325
328
method : opts . method ,
326
329
onRequest : opts . onRequest as OfetchOptions [ 'onRequest' ] ,
327
330
onRequestError : opts . onRequestError as OfetchOptions [ 'onRequestError' ] ,
@@ -530,6 +533,7 @@ export const createConfig = <T extends ClientOptions = ClientOptions>(
530
533
) : Config < Omit < ClientOptions , keyof T > & T > => ( {
531
534
...jsonBodySerializer ,
532
535
headers : defaultHeaders ,
536
+ ignoreResponseError : true ,
533
537
parseAs : 'auto' ,
534
538
querySerializer : defaultQuerySerializer ,
535
539
...override ,
You can’t perform that action at this time.
0 commit comments