- Introduction
- Getting started
- Philosophy
- Comparison
- Limitations
- Debugging runbook
- FAQ
- Basics
- Concepts
- Network behavior
- Integrations
- API
- CLI
- Best practices
- Recipes
- Cookies
- Query parameters
- Response patching
- Polling
- Streaming
- Network errors
- File uploads
- Responding with binary
- Custom worker script location
- Global response delay
- GraphQL query batching
- Higher-order resolver
- Keeping mocks in sync
- Merging Service Workers
- Mock GraphQL schema
- Using CDN
- Using custom "homepage" property
- Using local HTTPS
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.