- Introduction
- Getting started
- Philosophy
- Comparison
- Limitations
- Debugging runbook
- FAQ
- Basics
- Concepts
- Network behavior
- Integrations
- API
- CLI
- Best practices
- Recipes
passthrough
Handle the intercepted request by performing it as-is.
Call signature
function passthrough(): Response {}
passthrough.ts
Source code for the `passthrough` namespace.
Usage
import { http, passthrough, HttpResponse } from 'msw'
export const handlers = [
http.get('/resource', ({ request }) => {
if (request.headers.has('x-my-header')) {
return passthrough()
}
return HttpResponse.text('Mocked response')
}),
]
Unlike bypass()
, the passthrough()
function does not result in an additional request, and is designed to explicitly pass through an intercepted request within the response resolver. Because of this, the passthrough()
function cannot be used to perform an additional request, only to handle an already intercepted one.
Related materials
bypass
Perform an additional request outside of the interception algorithm.