Network errors

Reproduce a network error response.

Use the HttpResponse.error() static method (the mirror of Response.error()) to create a network error response.

Unlike server error responses, network errors reject the request promise and represent a failed request operation. Some of the examples of network errors include:

  • Connectivity issues (e.g. the client became offline);
  • DNS lookup failures (e.g. connecting to a non-existing host);


import { http, HttpResponse } from 'msw'
export const handlers = [
  http.get('/resource', () => {
    // Respond with a network error.
    return HttpResponse.error()