Uniform failure reporting middleware.
Admits only 2xx responses from the wrapped Fetch implementation, reporting error responses and transport failures alike as problems.
Usage
import { createFetch, NotFound } from "@metreeca/http";import { success } from "@metreeca/http/success";const client = createFetch(success()); // rejects unless response.oktry { const response = await client("https://api.example.com/data");} catch ( problem ) { // a Problem, whatever went wrong if ( problem.status === NotFound ) { // handle a missing resource }} Copy
import { createFetch, NotFound } from "@metreeca/http";import { success } from "@metreeca/http/success";const client = createFetch(success()); // rejects unless response.oktry { const response = await client("https://api.example.com/data");} catch ( problem ) { // a Problem, whatever went wrong if ( problem.status === NotFound ) { // handle a missing resource }}
RFC 9457 - Problem Details for HTTP APIs
Problem details for HTTP APIs.
Creates a middleware admitting only 2xx responses, reporting failures as problems.
Uniform failure reporting middleware.
Admits only 2xx responses from the wrapped Fetch implementation, reporting error responses and transport failures alike as problems.
Usage
See
RFC 9457 - Problem Details for HTTP APIs