UNPKG

fetch-check-http-status

Version:

A simple response handler which rejects fetch requests on any non-2xx response.

17 lines (13 loc) 355 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = checkStatus; function checkStatus(response) { var status = response.status; var statusText = response.statusText; if (status >= 200 && status < 300) return response; var error = new Error(statusText); error.response = response; throw error; }