Skip to content

BlackGlory/extra-response

Repository files navigation

extra-response

Utilities for Response.

Install

npm install --save extra-response
# or
yarn add extra-response

API

ok

ok(res: Response): Promise<Response>

If res.ok is false, it will throw HTTPError.

toJSON

toJSON(res: Response): Promise<Json>

toText

toText(res: Response, charset?: string): Promise<string>

toLines

toLines(res: Response): AsyncIterable<string>

Only available on browser, because node-fetch is not provide the WHATWG ReadableStream as body.

toNDJSON

toNDJSON(res: Response): AsyncIterable<Json>

Only available on browser, because node-fetch is not provide the WHATWG ReadableStream as body.