How do I access the response body from an error? #1991
-
I am calling an API that can responds with HTTP code 409 and a response body as below.
I tried calling this api using got as below.
But the logs doesn't show the body. Is it possible to catch it?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The |
Beta Was this translation helpful? Give feedback.
-
Here's how I ended up with a much clearer logged error for my use case:
Use it like so:
✌️ |
Beta Was this translation helpful? Give feedback.
The
response
, meaning also thebody
, is attached to the error. It's all in the docs. The response is not visible when logging for practical reasons (the object is huge) and security reasons.