Skip to content

Releases: sindresorhus/got

v10.0.0-alpha.2

23 Sep 14:45
Compare
Choose a tag to compare
v10.0.0-alpha.2 Pre-release
Pre-release

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 got@10.0.0-alpha.2.2

Make sure you also read the alpha.1 release notes.

Changes in alpha.2:

  • Export useful TypeScript types for end-users (#889) afe3081
  • Fix types: Allow custom retry options (#884) ce8e15b
  • Fix types: Allow promises in afterResponse hook (#883) d0c2f05

v10.0.0-alpha.1...v10.0.0-alpha.2

v10.0.0-alpha.1

17 Sep 09:20
Compare
Choose a tag to compare
v10.0.0-alpha.1 Pre-release
Pre-release

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 got@10.0.0-alpha.1.1

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 to searchParams 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:
- got(…, {query: …});
+ got(…, {searchParams: …});
  • Replace the baseUrl option with prefixUrl (#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:
- 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 the responseType 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:
- got(url, {body: {x: true}, json: true});
+ got.post(url, {json: {x: true}}).json();
  • Don't infer POST automatically when specifying body (#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 into retries.limit and retries.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. Use instanceA.extend(instanceB) instead.
    • Migrate:
- 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

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

v9.6.0...v10.0.0-alpha.1

v9.6.0

17 Jan 05:05
Compare
Choose a tag to compare

v9.5.1...v9.6.0

v9.5.1

13 Jan 06:11
Compare
Choose a tag to compare
  • Fix memory leak when using socket timeout and keepalive agent (#694) 203dadc
  • Fix strange timing data for HTTP requests d136e61
  • Correctly preserve original status code when returning cached responses d136e61

v9.5.0...v9.5.1

v9.5.0

18 Dec 15:09
Compare
Choose a tag to compare
  • Remove error thrown for URLs with auth component (#676) 5d20a43
  • Upgrade dependencies a1eadfe

v9.4.0...v9.5.0

v9.4.0

10 Dec 21:06
Compare
Choose a tag to compare
  • Add ability to specify which network error codes to retry on. 9f3a099
  • Add Got options onto responses and errors. 33b838f
  • Correctly clear socket timeout on error. c8e358f

v9.3.2...v9.4.0

v9.3.2

08 Nov 16:20
Compare
Choose a tag to compare

v9.3.1...v9.3.2

v9.3.1

03 Nov 12:21
Compare
Choose a tag to compare
  • Don't override headers defined in the url argument when it's an object. 191e00a
  • Don't set content-length header when upload body size is null. 311b184

v9.3.0...v9.3.1

v9.3.0

30 Oct 09:04
Compare
Choose a tag to compare
  • Add option to allow defaults to be mutable. b392f60
  • Add beforeRedirect, beforeRetry, and afterResponse hooks. 325409c
  • Retry on a few more errors. fbaaa2a
  • Include body property in HTTPError. fdc0fa6
  • Transform user set headers to lowercase. a07b2be
  • Support Electron renderer timings. 25f18be

v9.2.0...v9.3.0

v9.2.2

17 Sep 05:22
Compare
Choose a tag to compare
  • Gracefully handle invalid Location redirect URLs. (#605) 7ae6939
  • Don't override hooks when merging arguments. 3ad3950
  • Merge hooks on got.extend(). (#608) 292f78a

v9.2.1...v9.2.2