LOGOMock Service Worker
  1. Api
  2. request
  3. passthrough

passthrough

Use the req.passthrough method of the intercepted request to explicitly state that you wish for the library to bypass this request (perform as-is).

Since version 0.40.0, returning undefined/null from a response resolver will consider the intercepted request as unhandled.
1import { rest } from 'msw'
2
3export const handlers = [
4 rest.post('/user', (req, res, ctx) => {
5 // Perform the intercepted "POST /user" request as-is
6 // if its query string has the "id" parameter.
7 if (req.url.searchParams.has('id')) {
8 return req.passthrough()
9 }
10
11 // Otherwise, return a mocked "text/plain" response.
12 return res(ctx.text('hello'))
13 })
14]