# Data flow — unjs/ofetch

> Canonical page: https://codevetter.com/unpack/ofetch/data-flow

# Data flow — unjs/ofetch

Scanned commit 1dbc37fd1ceab832fc7c90cad81b1091c95ba563 (2026-07-08). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Inputs enter as FetchRequest and FetchOptions, then become a mutable FetchContext. Resolution merges shared defaults with call-specific headers and query values before hooks and normalization. Fetch produces a Response whose body becomes _data, which hooks can inspect before return or rejection. Retries carry transformed context back through the same pipeline.
- Each raw call allocates a context containing the original request, resolved options, and initially undefined response and error fields. — [src/fetch.ts#L89-L103](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L89-L103) [src/types.ts#L94-L99](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L94-L99)
- Header resolution chooses explicit input headers over Request headers, then overlays them on defaults using Headers.set; it does not merge Request headers when explicit headers are supplied. — [src/utils.ts#L94-L99](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.ts#L94-L99) [src/utils.ts#L121-L137](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.ts#L121-L137) [test/index.test.ts#L385-L397](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/test/index.test.ts#L385-L397)
- Query precedence is default params, default query, input params, then input query; other options use shallow defaults/input spread. — [src/utils.ts#L101-L118](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.ts#L101-L118)
- Method capitalization precedes onRequest; that hook can change the request or options before string URL transformation and body serialization. — [src/fetch.ts#L105-L130](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L105-L130) [src/types.ts#L104-L110](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L104-L110)
- withQuery omits undefined values in new queries; in existing queries it deletes undefined keys, appends array elements, and replaces scalar values. — [src/utils.url.ts#L64-L102](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.url.ts#L64-L102)
- Query normalization turns null into an empty string, numbers and booleans into strings, and objects into JSON; serialization uses URLSearchParams. — [src/utils.url.ts#L72-L83](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.url.ts#L72-L83) [src/utils.url.ts#L105-L118](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.url.ts#L105-L118)
- Truthy timeout adds a generated AbortSignal, optionally combined with the caller signal, before resolved options cross the fetch boundary as RequestInit. — [src/fetch.ts#L171-L184](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L171-L184)
- Decoded data belongs to response._data; the normal client returns that value, while FetchError getters retain access to context and parsed error data. — [src/fetch.ts#L215-L230](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L215-L230) [src/fetch.ts#L259-L262](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L259-L262) [src/error.ts#L44-L63](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/error.ts#L44-L63)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
