-
-
Notifications
You must be signed in to change notification settings - Fork 969
Closed
Labels
Description
Describe the bug
- Node.js version: v12.14.1
- OS & version: Linux AMA-LT-4549 4.15.0-76-generic Issue when using both
path
andquery
options #86~16.04.1-Ubuntu SMP Mon Jan 20 11:02:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Currently the snippet provided in the code to reproduce
section fails.
got
tries to mutate the options
object. This currently impacts test scenarii where the same options
object is used between different tests.
Actual behavior
> node .
(node:12424) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'body' of undefined
at /home/user/dev/got-issue/index.js:12:32
(node:12424) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:12424) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Expected behavior
No mutation.
Code to reproduce
const got = require('got');
const options = {};
Object.freeze(options);
(async () => {
try {
const response = await got('https://sindresorhus.com', options);
console.log(response.body);
//=> '<!doctype html> ...'
} catch (error) {
console.log(error.response.body);
//=> 'Internal server error ...'
}
})();
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.
stefanprobst