Variable errorType

errorType: ((errorType: string) => void)

Type declaration

    • (errorType: string): void
    • Sets the default method (text, json, …) used to parse the data contained in the response body in case of an HTTP error. As with other static methods, it will affect wretch instances created after calling this function.

      import wretch from "wretch"

      wretch.errorType("json")

      wretch("http://server/which/returns/an/error/with/a/json/body")
      .get()
      .res()
      .catch(error => {
      // error[errorType] (here, json) contains the parsed body
      console.log(error.json)
      })

      If null, defaults to "text".

      Parameters

      • errorType: string

      Returns void

Generated using TypeDoc