-
-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
Description
Describe the bug
- Node.js version: v14.14.0
- OS & version: Fedora 33
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:
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)
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
const got = require("got");
await got("https://api.github.com/user", {throwHttpErrors: false}).json();Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
Reactions are currently unavailable