- 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
- Remote Request Interception
- Using CDN
- Using custom "homepage" property
- Using local HTTPS
resetHandlers()
Reset request handlers to the initial list.
Call signature
The server.resetHandlers()
method can be called without any arguments. When done so, all the Runtime request handlers (those prepended via server.use()
) will be removed.
const server = setupServer(http.get('/resource', resolver))
server.use(http.post('/user', resolver))
server.resetHandlers()
// The "POST /user" runtime request handler is removed,
// and only the "GET /resource" initial request handler remains.
The server.resetHandlers()
method also accepts an optional list of request handlers spread as its arguments. When such a list is provided, the initial request handlers passed to setupServer()
will also be removed, and the given list of request handlers would act as the initial handlers.
const server = setupServer(http.get('/resource', resolver))
server.use(http.post('/user', resolver))
server.resetHandlers(http.patch('/book/:bookId', resolver))
// Both the runtime "POST /user" and the initial "GET /resource"
// request handlers are removed, and only the "PATCH /book/:bookId"
// request handler remains.