Closed ikorolev93 closed 3 years ago
why have you closed this issue ? actually i have the same problem now with got version 11.8.2
const host = 'your_host';
const opts: OptionsOfJSONResponseBody = {
...,
throwHttpErrors: false,
...,
}
const res = await got(host, opts).json<ExpectedResponseType>()
Code above throws exception
TypeError: Cannot read property 'request' of undefined
at /path/to/my/project/node_modules/got/dist/source/as-promise/index.js:157:48
at processTicksAndRejections (internal/process/task_queues.js:93:5)
why have you closed this issue ?
actually i have the same problem now with got version 11.8.2
Please open another issue with the full code to reproduce the bug.
Describe the bug
When the server returns an error code with JSON body, and I try to parse it using
.json()
and{throwHttpErrors: false}
, I get the following error:Actual behavior
TypeError is thrown
Expected behavior
Returning the body of response, parsed as JSON (matching the behavior of
{responseType: 'json', resolveOnlyBody: true}
, as documented)Code to reproduce
https://runkit.com/embed/3tt06wxjbio1
Checklist