Skip to content

response.ok is always true #22

@lmachens

Description

@lmachens

👋 thank you for this great module.

I noticed, that an APIError is thrown if response.ok is falsy:

if (result.ok) {
return result
}
throw new ApiError(result)

ok is omitted in ApiError constructor:

constructor(response: Omit<ApiResponse, 'ok'>) {

This means, that you always have true for ok, because it is not part of the error response.

It's not a real issue, but I expected that I could check for ok by myself to separate abnormal HTTP-statuses (4xx, 5xx) from network problems.
I suggest removing ok from the result, or do not throw an error if the response is not ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions