Skip to content

No way to access full error response body #296

Open
@cubeghost

Description

@cubeghost

According to the API docs, when dealing with 4xx errors, the body's response object sometimes contains more information about the error. It would be really useful to be able to access the full response from error callbacks or rejections in this library, but I'm not sure if it's possible at the moment.

The Node HTTP response object is passed as the third argument to callback, but by the time callback is called, the response body stream has already been consumed, so we can't access it. One workaround could be to pipe responseData back into the response stream right before calling callback.

Since it seems like callback is being deprecated, another approach could be to extend the Error class to add a property for the response body, which would give access to the full response when handling async/promise rejections.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions