Releases: sindresorhus/got
6.5.0
- 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 fixesunexpected EOF
error - Allow non-plain object as request body (#217)
Changes
6.3.0
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
6.2.0
6.1.2
6.1.1
6.1.0
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
5.3.1
6.0.0
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
5.3.0
5.2.0
- 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
});