got
16.2.0 · 30 Oct 2026MIT53.2M / weekRepositoryHomepagenpmAtom feed
10.7.0 is the newest release of 10.x.
In short
16 breaking16 new14 fixed7 internal
- Breaking
Require Node.js 10 633651f
- Breaking
Remove support for protocol-less URLs in the
urlargument 92bc808 - Breaking
Rename the
queryoption tosearchParamsand make it stricter b223663 5376216 518f0f5906e1fcd38691555b17fb91db643f3d47 - Breaking
Replace the
baseUrloption withprefixUrl(#829) 0d534ed - Breaking
Change the
jsonoption to accept an object instead of a boolean and to only be responsible for the request, not the response (#704) a6a7d5a - Breaking
Use the
responseTypeoption instead ofencodingto get a Buffer (#940) 6cc3d9f - Breaking
Don't infer
POSTautomatically when specifyingbody(#756) e367bdb - Breaking
The
retries.retryoption was split intoretries.limitandretries.calculateDelayb15ce1d
Security
1 advisory affects 10.0.0; 11.8.5 fixes them
- ModerateGot allows a redirect to a UNIX socketGHSA-pfrx-2q88-qq97 · 19 Jun 2022Fixed in 11.8.5
Release note
We're excited to announce Got 10! 🎉 This release has been in the works for almost a year and has been a major undertaking. Got was fully rewritten in TypeScript, which helped us catch many bugs and will give us more confidence in the codebase going forward. Got is now faster and much more stable. We also fixed a huge amount of bugs. Big thanks to everyone that helped make this release possible. 🙌
If you find Got useful, you might want to sponsor the Got maintainers.
Note: Some HTTP agents like https-proxy-agent and agentkeepalive are not compatible with Node.js 10 and hence not compatible with Got as Got takes advantage of some Node.js 10-only APIs.
Breaking
- Breaking
Require Node.js 10 633651f
Why: This is so that we can use
stream.pipelinefor more reliable stream handling. Node.js 8 will be out of LTS at the end of this month anyway.
- Breaking
Remove support for protocol-less URLs in the
urlargument 92bc808Why: To reduce ambiguity. It was not clear from just reading the code what it would default to.
Migrate:
- got('sindresorhus.com');
+ got('https://sindresorhus.com');- Breaking
Rename the
queryoption tosearchParamsand make it stricter b223663 5376216 518f0f5Why: To get closer to the
window.fetchnaming in the browser.Migrate:
- got(…, {query: …});
+ got(…, {searchParams: …});- Breaking
Replace the
baseUrloption withprefixUrl(#829) 0d534edNote: We also made it stricter to reduce ambiguity. The Got
urlargument now cannot be prefixed with a slash when this option is used.Why: We renamed it to make it clear that it doesn't do any URL resolution.
Migrate:
- got('/foo', {baseUrl: 'https://x.com'});
+ got('foo', {prefixUrl: 'https://x.com'});- Breaking
Change the
jsonoption to accept an object instead of a boolean and to only be responsible for the request, not the response (#704) a6a7d5aNote: You now set the request body in this option instead of the
bodyoption when you want to send JSON. This option also no longer sets the response type to JSON. You either call the.json()method or specify theresponseTypeoption for that.Why: Many people were confused how
{json: true}worked and they also complained that they could not set the request/response type individually.Migrate:
- got(url, {body: {x: true}, json: true});
+ got.post(url, {json: {x: true}}).json();- Breaking
Use the
responseTypeoption instead ofencodingto get a Buffer (#940) 6cc3d9fWhy: Previously, you would pass
{encoding: null}to get a Buffer, but this was confusing. You now use{responseType: 'buffer'}instead.Tip: You can also use
got(…).buffer();.Migrate:
- got(…, {encoding: null});
+ got(…, {responseType: 'buffer'});- Breaking
Don't infer
POSTautomatically when specifyingbody(#756) e367bdbWhy: We're trying to reduce the amount of magic behavior.
Migrate:
- got(…, {body: 'foo'});
+ got.post(…, {body: 'foo'});- Breaking
The
retries.retryoption was split intoretries.limitandretries.calculateDelayb15ce1dMigrate:
got(…, {
retry: {
- retries: 2
+ limit: 2
}
}); got(…, {
retry: {
- retries: iteration => iteration < 2
+ calculateDelay: ({attemptCount}) => attemptCount < 2
}
});- Breaking
Use
undefinedinstead ofnullto omit a header (github.com/sindresorhus/got) 518f0f5Why: We're trying to reduce the use of
null.Migrate:
got(…, {
headers: {
- 'user-agent': null
+ 'user-agent': undefined
}
});- Breaking
Rename the Promise API property
.fromCacheto.isFromCache(#768) b5e443b - Breaking
Rename the
streamoption toisStream518f0f5Why: To make it clearer that it's a boolean and that it doesn't expect a stream to be passed in.
Migrate:
- got(…, {stream: true});
+ got(…, {isStream: true});- Breaking
Don't include the Got version in the default
user-agentheader (#911) 95bed1egot/9.6.0 (https://github.com/sindresorhus/got)→got (https://github.com/sindresorhus/got)Why: Importing package.json to get the version caused a lot of problems. And you should ideally set your own
user-agentheader anyway.
- Breaking
Remove
got.create()518f0f5You can achieve the same thing with
got.extend()now.
- Breaking
Remove
got.mergeInstances()518f0f5Use
gotInstance.extend(...gotInstances)instead.
- Breaking
Move top-level error properties into an
.optionsand.responseproperty (#773) 6eaa81bMigrate:
- error.gotOptions + error.options - error.headers + error.response.headers - error.statusCode + error.response.statusCode - error.statusMessage + error.response.statusMessage - error.body + error.response.body - error.redirectUrls + error.response.redirectUrls - error.host + error.options.host - error.hostname + error.options.hostname - error.method + error.options.method - error.protocol + error.options.protocol - error.url + error.options.url - error.path + error.options.path
- Breaking
Custom instance creation was simplified (#707) 8eaef94
Note:
got.mergeInstances(...instances)is deprecated. UseinstanceA.extend(instanceB)instead.Migrate:
# Merging instances
- got.mergeInstances(instanceA, instanceB, instanceC, …);
+ instanceA.extend(instanceB, instanceC, …);
# Merging options
- instanceA.extend(optionsB).extend(optionsC).extend(…);
+ instanceA.extend(optionsB, optionsC, …);
# Merging instances and options
- got.mergeInstances(instanceA.extend(optionsB), instanceC);
+ instanceA.extend(optionsB, instanceC, …);
# Extending handlers
- got.mergeInstances(instanceA, got.create({handler: handlerB}));
+ instanceA.extend({handlers: [handlerB]});Enhancements
Got has been rewritten in TypeScript.
Why: This means we can provide our own type definitions and we can be more confident when working on the Got codebase and produce less bugs.
Add support for Brotli (Node.js 12 and later) (#706) d5d2e6f
Add
contextoption for storing custom metadata across request and hooks (#777) 3bb5aa7Add
maxRedirectsoption (#914) 0c505b0Add ability to use something other than
tough-cookiefor handling cookies (#882) 518f0f5Pass the response as the second argument to the
beforeRedirecthook (#812) 3557896Throw on canceled request with incomplete response (#767) 92b1005
Add
.isFromCacheproperty to the stream API (#768) b5e443bThe
timeoutoption can now be modified in hooks d520a3aThe
prefixUrloption can now be modified in hooks (#867) 518f0f5
Fixes
Fix parsing response when using
afterResponsehook (#775) e2054cdFix default
retryoption value when specifying a number (#809) 9c04a7cCorrectly handle promise- and stream-specific errors in the
beforeErrorhook 134c9b7Don't throw on early lookups 4faf5c7
Don't throw on
204 No Contentwhen parsing response (#925) 518f0f5When redirect fails, don't retry from scratch (#930) 518f0f5
Retrying inside
afterResponsehook should triggerbeforeRetryhook (#918) 518f0f5Fix a bug that sometimes caused the Node.js process to hang 518f0f5
Fix a bug where cookies weren't reset on redirect between two different sites 518f0f5
Make the progress events not be based on internal Node.js properties cd11a50
All commits
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.