Skip to content

Releases: sindresorhus/got

6.5.0

14 Sep 09:12
Compare
Choose a tag to compare
  • Add a redirect url property to the response object (#191)
  • Add a requestUrl property to the response object (#205)
  • ⬆️ get-stream bumped to ^2.3.0 – which fixes some nasty encoding bugs
  • Fix location encoding (#214)
  • Detect formdata body and set content-type header (#220)
  • ⬆️ unzip-response bumped to ^2.0.1 – which fixes unexpected EOF error
  • Allow non-plain object as request body (#217)

Changes

v6.3.0...v6.5.0

6.3.0

06 Apr 18:37
Compare
Choose a tag to compare

followRedirect option

This option disables following redirects and got will not treat them as errors:

const res = await got(`google.com`, {followRedirect: false});
res.statusCode === 302; // true

By default this option is true, so no major changes in code are needed.

Changes

v6.2.0...v6.3.0

6.2.0

03 Mar 08:06
Compare
Choose a tag to compare
  • 26a499c statusCode and statusMessage added to ParseError object

6.1.2

03 Mar 08:09
Compare
Choose a tag to compare
  • 45a636c fixes errors on parsing empty JSON body
  • f9078b6 fixes default user-agent to be RFS complaint

6.1.1

03 Mar 08:09
Compare
Choose a tag to compare
  • f9ef29a fixes redirects with uppercased method option

6.1.0

16 Jan 11:32
Compare
Choose a tag to compare

Non-retrieable errors

In got@5 we introduced retries option, which (as name says) retry request on every Error. For most errors this was right thing to do, but in case ENETUNREACH and ENOTFOUND retries are pointless.

This version removes retries from such errors, so you will get instant error, when typo gets into configs.

Changes

v6.0.0...v6.1.0

5.3.1

12 Jan 10:46
Compare
Choose a tag to compare
  • 43a6ea5 Missing exception in helper methods for stream mode.
  • 436600f Fixed piping response in response event for stream mode.

v5.3.0...v5.3.1

6.0.0

07 Jan 18:58
Compare
Choose a tag to compare

Aiming on Node.js 4

This release drops Node.js 0.10/0.12 support, so we replaced lots of modules and reduce dependency tree more than twice (see PR overview). Module folder size reduced from 1.1 MB to 216 KB.

For older Node.js versions we will still maintain v5.x for critical bug-fixes.

Promises by default

Callback interface was replaced by Promises, because it is a better way to work with asynchronous operations and they can be used with yield/await nicely.

If you use callback before:

got('todomvc.com', (err, body) => {
    if (err) {
        console.log(err);
        return;
    }

    console.log(body);
});

You can rewrite it this way:

got('todomvc.com')
    .then(res => {
        console.log(res.body);
    })
    .catch(err => {
        console.log(err);
    });

You can read more about Promises in "ECMAScript 6 promises (2/2): the API" post and some caveats in "We have a problem with promises".

Update

$ npm install --save got@6

Changes

v5.3.0...v6.0.0

5.3.0

20 Dec 17:29
Compare
Choose a tag to compare
  • 59aa1d3 Error is passed to retries function as well
  • da9fc07 Unzipping HEAD requests is disabled

v5.2.0...v5.3.0

5.2.0

02 Dec 07:57
Compare
Choose a tag to compare
  • 54bd6f5 default intervals between delays decreased - now they are around 1s, 2s, 4s, 8s, etc...
  • a10a99e retries option accepts backoff function, for example you can:
// Constant delay of 10ms for 5 iterations
got('google.com', {
    retries: iter => iter < 5 && 10
});

// Infinity retries with constant delay
got('google.com', {
    retries: () => 10
});

v5.1.0...v5.2.0