0.3.0 • Published 1 month ago

@contentgrid/problem-details v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@contentgrid/problem-details

RFC 9457 Problem Details types and helpers

Usage

import { ProblemDetail, ProblemDetailError, checkResponse } from '@contentgrid/problem-details'

// Fetch data from somewhere
fetch('/some-url')
    .then(checkResponse) // Throws ProblemDetailError if an error response is returned
    .then(response => {
        // Handle succesfull response
    }, error => {
        // Handle error response
        if(error instanceof ProblemDetailError) {
            // ProblemDetail is available on the ProblemDetailError
            console.error("Failed to fetch", error.problemDetail.title)
        } else {
            console.error("Failed to fetch", error);
        }
    })
0.3.0

1 month ago

0.2.0

8 months ago