Skip to content

When a server returns an error status code without content, the error is present but undefined #2530

@julienw

Description

@julienw

openapi-fetch version

Latest

Description

The context is this code:

return response.ok ? { data: undefined, response } : { error: undefined, response };

I wonder if we shouldn't have a tru-ish value (maybe just "true") for error here, so that the calling code can simply use if (error). What do you think?

Reproduction

The problem happens when a server returns an error status (such as 405) without any content.

Expected result

The caller can do if (error) simply.

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-fetchRelevant to the openapi-fetch library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions