Defjs
Core

createHttpInterceptor

Wraps an InterceptorFn as a tagged HttpInterceptor.

@defjs/core · Function

Signature

function createHttpInterceptor(fn: InterceptorFn): HttpInterceptor;

Returns { kind: 'http', fn }. Call next(req) (optionally with a modified request) or short-circuit with makeResponse. next runs only the interceptors registered after this one and then the fetch handler. HTTP interceptors do not run for SSE or WebSocket operations.

A deterministic URL error from next(req) rejects the returned promise, so .then or .catch recovery runs; if it is not recovered, the operation still reports REQ_BUILD_FAILED.

Parameters

Prop

Type

fn InterceptorFn

HTTP interceptor function.

Returns

An HttpInterceptor with kind: 'http'.

Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao