@contentgrid/problem-details
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

@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);
        }
    })

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @contentgrid/problem-details

    Weekly Downloads

    50

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    11.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • xenit-jenkins