Releases: sindresorhus/got
v10.0.0-beta.1
While this is an beta release, the code is well-tested and fairly stable. We encourage you to test it out and report any issues.
$ npm install [email protected]
Make sure you also read the alpha.1
, alpha.2
, and alpha.3
release notes.
Changes in beta 1:
Breaking
- Remove the
query
option in favor of thesearchParams
option (It was previously deprecated) 518f0f5 - Rename the
stream
option toisStream
518f0f5 - Don't include the Got version in the default
user-agent
header (#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.
- Remove
got.create()
518f0f5- You can achieve the same thing with
got.extend()
now.
- You can achieve the same thing with
- Remove
got.mergeInstances()
518f0f5- Use
gotInstance.extend(...gotInstances)
instead.
- Use
- Use
undefined
instead ofnull
to omit a header (https://github.com/sindresorhus/got#headers) 518f0f5
Enhancements
- Add
maxRedirects
option (#914) 0c505b0 - Add ability to use something other than
tough-cookie
for handling cookies (#882) 518f0f5 - Allow method rewriting on redirects (#913) b7ead5f
options.timeout
can now be modified in hooks d520a3aoptions.prefixUrl
can now be modified in hooks (#867) 518f0f5- Only allow supported event names when using TypeScript (#877) 518f0f5
Fixes
- Fix Node.js 13 compatibility (#915) b0dfc95
- Fix memory leak when using cache feature (#792) 518f0f5
- Don't throw on
204 No Content
when parsing response (#925) 518f0f5 - When redirect fails, don't retry from scratch (#930) 518f0f5
- Retrying inside
afterResponse
hook should triggerbeforeRetry
hook (#918) 518f0f5 - Fix a bug that sometimes caused the Node process to hang 518f0f5
- Fix a bug where cookies weren't reset on redirect between two different sites 518f0f5
Docs
v10.0.0-alpha.3
While this is an alpha release, the code is well-tested and fairly stable. We encourage you to test it out and report any issues.
$ npm install [email protected]
Note the .2
at the end
Make sure you also read the alpha.1
and alpha.2
release notes.
Changes in alpha.3:
Breaking
- Require Node.js 10 633651f
This is so that we can usestream.pipeline
for more reliable stream handling. Node.js 8 will be out of LTS in a month anyway.
Enhancements
Fixes
v10.0.0-alpha.2
While this is an alpha release, the code is well-tested and fairly stable. We encourage you to test it out and report any issues. However, we don't recommend TypeScript users to use this yet as the types are incomplete.
$ npm install [email protected]
Make sure you also read the alpha.1
release notes.
Changes in alpha.2:
v10.0.0-alpha.1
While this is an alpha release, the code is well-tested and fairly stable. We encourage you to test it out and report any issues. However, we don't recommend TypeScript users to use this yet as the types are incomplete.
$ npm install [email protected]
Breaking
- Remove support for protocol-less URLs in the
url
argument 92bc808- Why: 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');
- Rename the
query
option tosearchParams
and make it stricter b223663 5376216- Note: The
query
option name is still supported, but it will be removed in the next major version. - Why: To get closer to the
window.fetch
naming in the browser. - Migrate:
- Note: The
- got(…, {query: …});
+ got(…, {searchParams: …});
- Replace the
baseUrl
option withprefixUrl
(#829) 0d534ed- Note: We also made it stricter to reduce ambiguity. The Got
url
argument now cannot be prefixed with a slash when this option is used. - Why: To make it clear that it doesn't do any URL resolution.
- Migrate:
- Note: We also made it stricter to reduce ambiguity. The Got
- got('/foo', {baseUrl: 'https://x.com'});
+ got('foo', {prefixUrl: 'https://x.com'});
- Change the
json
option to accept an object instead of a boolean and to only be responsible for the request, not the response (#704) a6a7d5a- Note: You now set the request body in this option instead of the
body
option 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 theresponseType
option for that. - Why: Many people were confused how
{json: true}
worked and they also complained that they could not set the request/response individually. - Migrate:
- Note: You now set the request body in this option instead of the
- got(url, {body: {x: true}, json: true});
+ got.post(url, {json: {x: true}}).json();
- Don't infer
POST
automatically when specifyingbody
(#756) e367bdb- Why: We're trying to reduce the amount of magic behavior.
- Migrate:
- got(…, {body: 'foo'});
+ got.post(…, {body: 'foo'});
- The
retries.retry
option was split intoretries.limit
andretries.calculateDelay
b15ce1d- Migrate:
got(…, {
retry: {
- retries: 2
+ limit: 2
}
});
got(…, {
retry: {
- retries: iteration => iteration < 2
+ calculateDelay: ({attemptCount}) => attemptCount < 2
}
});
- Rename the Promise API property
.fromCache
to.isFromCache
(#768) b5e443b - Move top-level error properties into an
.options
and.response
property (#773) 6eaa81b- Migrate:
- 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
- Custom instance creation was simplified (#707) 8eaef94
- Note:
got.mergeInstances(...instances)
is deprecated. UseinstanceA.extend(instanceB)
instead. - Migrate:
- Note:
- got.create({handler: handler});
+ got.create({handlers: [handler]});
# 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]});
Note: The notes here will be expanded in the final release.
Enhancements
- Got has been rewritten in TypeScript.
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 opt-in DNS cache (#731) cd12351
- Add
context
option for storing custom metadata across request and hooks (#777) 3bb5aa7 - Add option to ignore invalid cookies (#826) e9c01e0
- Proxy headers from server request to Got (#772) 00e5fd5
- Pass the response as the second argument to the
beforeRedirect
hook (#812) 3557896 - Make
URLSearchParams
instances mergeable (#734) 95c7c2c - Throw on canceled request with incomplete response (#767) 92b1005
- Add
[.isFromCache
property](https://github.com/sindresorhus/got#streams-1) to the stream API (#768) b5e443b
Fixes
- Fix parsing response when using
afterResponse
hook (#775) e2054cd - Fix
port
not being reset on redirect (#729) ada5861 - Fix the retry functionality (#787) 0501e00
- Fix default
retry
option value when specifying a number (#809) 9c04a7c - Correctly handle promise- and stream-specific errors in the
beforeError
hook 134c9b7 - Don't throw on early lookups 4faf5c7
Docs
- Document that
retry
option doesn't work with streams 9088866 - Encourage using
Stream.pipeline()
when using the stream API 06afb27 - Add instructions for
global-agent
(#822) ca8c560 - Mention the
TimeoutError.timings
property 8fa18f4