@wolfstar/safe-fetch
v1.1.10
Published
A fetch wrapper on top of Rust's Result
Maintainers
Readme
@wolfstar/safe-fetch
A fetch wrapper on top of Rust-style Result, so requests never throw.
Description
A fetch wrapper on top of Rust's Result, powered by @sapphire/result.
Features
- Powered by the native
fetchfunction - CJS and ESM support
Usage
import { Json, safeFetch } from '@wolfstar/safe-fetch';
const result = await Json<{ id: number; name: string }>(safeFetch('https://api.example.org/users/1'));
result.match({
ok: (user) => console.log(user.name),
err: (error) => console.error(error)
});