Description
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