UNPKG

@tkrotoff/fetch

Version:
16 lines (15 loc) 477 B
import { jsonMimeType } from './Http'; import { HttpError } from './HttpError'; export function createHttpError(body, status, statusText) { return new HttpError(undefined, new Response(body, { status, statusText })); } export function createJSONHttpError(body, status, statusText) { return new HttpError(undefined, new Response(JSON.stringify(body), { status, statusText, headers: { 'content-type': jsonMimeType } })); }