2.0.0 • Published 1 year ago

@await-to/ky v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@await-to/ky

Install

npm i @await-to/chainable
npm i @await-to/ky

Example

import { to, OkResult } from '@await-to/chainable';
import { awaitToKy } from '@await-to/ky';
import { ky } from 'ky';

const result = await to(ky.get('https://example.com').json())
	.and(awaitToKy())
	.get();

if (!result.ok) {
	// if ky resolved with a HTTPError, `awaitToKy` will resolve it
	// first as error.response.json()
	// or as secodnd option as error.response.text()
	result.error;
}