node-fetch/docs/v3-UPGRADE-GUIDE.md

145 lines
6.3 KiB
Markdown
Raw Permalink Normal View History

merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
# Upgrade to node-fetch v3.x
node-fetch v3.x brings about many changes that increase the compliance of
WHATWG's [Fetch Standard][whatwg-fetch]. However, many of these changes mean
that apps written for node-fetch v2.x needs to be updated to work with
node-fetch v3.x and be conformant with the Fetch Standard. This document helps
you make this transition.
Note that this document is not an exhaustive list of all changes made in v3.x,
but rather that of the most important breaking changes. See our [changelog] for
other comparatively minor modifications.
- [Breaking Changes](#breaking)
- [Enhancements](#enhancements)
---
<a id="breaking"></a>
# Breaking Changes
## Minimum supported Node.js version is now 12.20
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
Since Node.js 10 has been deprecated since May 2020, we have decided that node-fetch v3 will drop support for Node.js 4, 6, 8, and 10 (which were previously supported). We strongly encourage you to upgrade if you still haven't done so. Check out the Node.js official [LTS plan] for more information.
## Converted to ES Module
This module was converted to be a ESM only package in version `3.0.0-beta.10`.
`node-fetch` is an ESM-only module - you are not able to import it with `require`. We recommend you stay on v2 which is built with CommonJS unless you use ESM yourself. We will continue to publish critical bug fixes for it.
Alternatively, you can use the async `import()` function from CommonJS to load `node-fetch` asynchronously:
```js
// mod.cjs
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
```
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
2020-05-25 04:30:05 -07:00
## The `timeout` option was removed.
Since this was never part of the fetch specification, it was removed. AbortSignal offers more fine grained control of request timeouts, and is standardized in the Fetch spec. For convenience, you can use [timeout-signal](https://github.com/node-fetch/timeout-signal) as a workaround:
2020-05-25 04:30:05 -07:00
```js
import timeoutSignal from 'timeout-signal';
import fetch from 'node-fetch';
2020-05-25 04:30:05 -07:00
const {AbortError} = fetch
Require Node.js 12.20.0 and move to ESM (#1141) * Use ESM import in runkit example file * Update dependencies, version and transition to ESM * Use ESM imports, add ESM-related info * Remove rollup * Lint TypeScript-related files * Update dependency * Lint & update dependency * Lint * Remove commonjs tests * chore: update changelog * Remove commonjs GitHub action * Update funding.yml * Update linter rules * Lint * Fix tsd * Remove unnecessary types * Simplify * Use top-level await * Update GitHub Actions * Use Mocha with ESM * Revamp * specify what node version * update formdata-node dep * remove lint from example using top await * updated name and link to formdata-polyfill * Stop recommend form-data * filter example - it has many duplicate variables * Update type definitions to ESM * Remove unused lint rule disable comment * Remove leftover rollup and dist folder * updated depn * updated d.ts * lint * Fix breaking changes with blob v3 stream() * revert eslint comment * revert back to xo 0.39 Don't want to deal with all those new rules right now. will fix it later fixed some of them... * none TS fan trying to fix type definition * Give me a break * Test on all minimum supported Node.js versions (#1170) * Test on all minimum supported Node.js versions * Tweak Node.js workaround version range * Handle Node.js 16 aborted error message * fix node version string compare Co-authored-by: Jimmy Wärting <jimmy@warting.se> * bumped fetch-blob version * import from dom lib * rm unused comment * updated required version in docs * fixed named import * set lowest support to 12.20.0 * comment explaining both * rm log Co-authored-by: Jimmy Wärting <jimmy@warting.se> Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
2021-07-18 13:15:19 -07:00
2020-05-25 04:30:05 -07:00
fetch('https://www.google.com', { signal: timeoutSignal(5000) })
.then(response => {
// Handle response
})
.catch(error => {
if (error instanceof AbortError) {
// Handle timeout
}
})
```
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
## `Response.statusText` no longer sets a default message derived from the HTTP status code
If the server didn't respond with status text, node-fetch would set a default message derived from the HTTP status code. This behavior was not spec-compliant and now the `statusText` will remain blank instead.
## Dropped the `browser` field in package.json
Prior to v3.x, we included a `browser` field in the package.json file. Since node-fetch is intended to be used on the server, we have removed this field. If you are using node-fetch client-side, consider switching to something like [cross-fetch].
## Dropped the `res.textConverted()` function
If you want charset encoding detection, please use the [fetch-charset-detection] package ([documentation][fetch-charset-detection-docs]).
```js
import fetch from 'node-fetch';
import convertBody from 'fetch-charset-detection';
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
fetch('https://somewebsite.com').then(async res => {
const buf = await res.arrayBuffer();
const text = convertBody(buf, res.headers);
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
});
```
## JSON parsing errors from `res.json()` are of type `SyntaxError` instead of `FetchError`
When attempting to parse invalid json via `res.json()`, a `SyntaxError` will now be thrown instead of a `FetchError` to align better with the spec.
```js
import fetch from 'node-fetch';
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
2020-03-13 10:01:45 -07:00
fetch('https://somewebsitereturninginvalidjson.com').then(res => res.json())
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
// Throws 'Uncaught SyntaxError: Unexpected end of JSON input' or similar.
```
## A stream pipeline is now used to forward errors
If you are listening for errors via `res.body.on('error', () => ...)`, replace it with `res.body.once('error', () => ...)` so that your callback is not [fired twice](https://github.com/node-fetch/node-fetch/issues/668#issuecomment-569386115) in NodeJS >=13.5.
## `req.body` can no longer be a string
We are working towards changing body to become either null or a stream.
## Changed default user agent
The default user agent has been changed from `node-fetch/1.0 (+https://github.com/node-fetch/node-fetch)` to `node-fetch (+https://github.com/node-fetch/node-fetch)`.
## Arbitrary URLs are no longer supported
Since in 3.x we are using the WHATWG's `new URL()`, arbitrary URL parsing will fail due to lack of base.
# Enhancements
## Data URI support
Previously, node-fetch only supported http url scheme. However, the Fetch Standard recently introduced the `data:` URI support. Following the specification, we implemented this feature in v3.x. Read more about `data:` URLs [here][data-url].
## New & exposed Blob implementation
Blob implementation is now [fetch-blob] and hence is exposed, unlikely previously, where Blob type was only internal and not exported.
## Better UTF-8 URL handling
We now use the new Node.js [WHATWG-compliant URL API][whatwg-nodejs-url], so UTF-8 URLs are handled properly.
## Request errors are now piped using `stream.pipeline`
Require Node.js 12.20.0 and move to ESM (#1141) * Use ESM import in runkit example file * Update dependencies, version and transition to ESM * Use ESM imports, add ESM-related info * Remove rollup * Lint TypeScript-related files * Update dependency * Lint & update dependency * Lint * Remove commonjs tests * chore: update changelog * Remove commonjs GitHub action * Update funding.yml * Update linter rules * Lint * Fix tsd * Remove unnecessary types * Simplify * Use top-level await * Update GitHub Actions * Use Mocha with ESM * Revamp * specify what node version * update formdata-node dep * remove lint from example using top await * updated name and link to formdata-polyfill * Stop recommend form-data * filter example - it has many duplicate variables * Update type definitions to ESM * Remove unused lint rule disable comment * Remove leftover rollup and dist folder * updated depn * updated d.ts * lint * Fix breaking changes with blob v3 stream() * revert eslint comment * revert back to xo 0.39 Don't want to deal with all those new rules right now. will fix it later fixed some of them... * none TS fan trying to fix type definition * Give me a break * Test on all minimum supported Node.js versions (#1170) * Test on all minimum supported Node.js versions * Tweak Node.js workaround version range * Handle Node.js 16 aborted error message * fix node version string compare Co-authored-by: Jimmy Wärting <jimmy@warting.se> * bumped fetch-blob version * import from dom lib * rm unused comment * updated required version in docs * fixed named import * set lowest support to 12.20.0 * comment explaining both * rm log Co-authored-by: Jimmy Wärting <jimmy@warting.se> Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
2021-07-18 13:15:19 -07:00
Since the v3.x requires at least Node.js 12.20.0, we can utilise the new API.
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
## Creating Request/Response objects with relative URLs is no longer supported
We introduced Node.js `new URL()` API in 3.x, because it offers better UTF-8 support and is WHATWG URL compatible. The drawback is, given current limit of the API (nodejs/node#12682), it's not possible to support relative URL parsing without hacks.
Due to the lack of a browsing context in Node.js, we opted to drop support for relative URLs on Request/Response object, and it will now throw errors if you do so.
The main `fetch()` function will support absolute URLs and data url.
## Bundled TypeScript types
Since v3.x you no longer need to install `@types/node-fetch` package in order to use `node-fetch` with TypeScript.
[whatwg-fetch]: https://fetch.spec.whatwg.org/
[data-url]: https://fetch.spec.whatwg.org/#data-url-processor
[LTS plan]: https://github.com/nodejs/LTS#lts-plan
[cross-fetch]: https://github.com/lquixada/cross-fetch
[fetch-charset-detection]: https://github.com/Richienb/fetch-charset-detection
[fetch-charset-detection-docs]: https://richienb.github.io/fetch-charset-detection/globals.html#convertbody
2020-06-05 10:00:13 -07:00
[fetch-blob]: https://github.com/node-fetch/fetch-blob#readme
merge 3.x into master branch (#745) * feat: Migrate TypeScript types (#669) * style: Introduce linting via XO * fix: Fix tests * chore!: Drop support for nodejs 4 and 6 * chore: Fix Travis CI yml * Use old Babel (needs migration) * chore: lint everything * chore: Migrate to microbundle * Default response.statusText should be blank (#578) * fix: Use correct AbortionError message Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use modern @babel/register Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove redundant packages Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Readd form-data Signed-off-by: Richie Bendall <richiebendall@gmail.com> * fix: Fix tests and force utf8-encoded urls Signed-off-by: Richie Bendall <richiebendall@gmail.com> * lint index.js * Update devDependencies & ignore `test` directory in linter options * Remove unnecessary eslint-ignore comment * Update the `lint` script to run linter on every file * Remove unused const & unnecessary import * TypeScript: Fix Body.blob() wrong type (DefinitelyTyped/DefinitelyTyped#33721) * chore: Lint as part of the build process * fix: Convert Content-Encoding to lowercase (#672) * fix: Better object checks (#673) * Fix stream piping (#670) * chore: Remove useless check Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Ensure all files are properly included Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps and utf8 should be in dependencies Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Drop Node v4 from tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Modernise code Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Move errors to seperate directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Add fetch-blob (#678) * feat: Migrate data uri integration Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Allow setting custom highWaterMark via node-fetch options (#386) (#671) * Expose highWaterMark option to body clone function * Add highWaterMark to responseOptions * Add highWaterMark as node-fetch-only option * a way to silently pass highWaterMark to clone * Chai helper * Server helper * Tests * Remove debug comments * Document highWaterMark option * Add TypeScript types for the new highWaterMark option * feat: Include system error in FetchError if one occurs (#654) * style: Add editorconfig Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore!: Drop NodeJS v8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove legacy code for node < 8 Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use proper checks for ArrayBuffer and AbortError Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Use explicitly set error name in checks Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Propagate size and timeout to cloned response (#664) * Remove --save option as it isn't required anymore (#581) * Propagate size and timeout to cloned response Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> * Update Response types * Update devDependencies * feat: Fallback to blob type (Closes: #607) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Update formatting Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix linting issues Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add info on patching the global object * docs: Added non-globalThis polyfill * Replace deprecated `url.resolve` with the new WHATWG URL * Update devDependencies * Format code in examples to use `xo` style * Verify examples with RunKit and edit them if necessary * Add information about TypeScript support * Document the new `highWaterMark` option * Add Discord badge & information about Open Collective * Style change * Edit acknowledgement & add "Team" section * fix table * Format example code to use xo style * chore: v3 release changelog * Add the recommended way to fix `highWaterMark` issues * docs: Add simple Runkit example * fix: Properly set the name of the errors. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add AbortError to documented types Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: AbortError proper typing parameters Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add example code for Runkit Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Replace microbundle with @pika/pack (#689) * gitignore the pkg/ directory * Move TypeScript types to the root of the project * Replace microbundle with @pika/pack * chore: Remove @pika/plugin-build-web and revert ./dist output directory Signed-off-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix incorrect statement in changelog * chore: v3.x upgrade guide * Change the Open Collective button * docs: Encode support button as Markdown instead of HTML * chore: Ignore proper directory in xo * Add an "Upgrading" section to readme * Split the upgrade guide into 2 files & add the missing changes about v3.x * style: Lint test and example files Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Move *.md files to the `docs` folder (except README.md) * Update references to files * Split LIMITS.md into 2 files (as of v2.x and v3.x) * chore: Remove logging statement Signed-off-by: Richie Bendall <richiebendall@gmail.com> * style: Fix lint * docs: Correct typings for systemError in FetchError (Fixes #697) * refactor: Replace `encoding` with `fetch-charset-detection`. (#694) * refactor: Replace `encoding` with `fetch-charset-detection`. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Move writing to stream back to body.js Signed-off-by: Richie Bendall <richiebendall@gmail.com> * refactor: Only put convertBody in fetch-charset-detection and refactor others. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * test: Readd tests for getTotalBytes and extractContentType Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Revert package.json indention Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove optional dependency * docs: Replace code for fetch-charset-detection with documentation. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove iconv-lite * fix: Use default export instead of named export for convertBody Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Remove unneeded installation of fetch-charset-detection in the build * docs: Fix typo * fix: Throw SyntaxError instead of FetchError in case of invalid… (#700) * fix: Throw SyntaxError instead of FetchError in case of invalid JSON Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Add to upgrade guide Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Remove deprecated url.parse from test * Remove deprecated url.parse from server * fix: Proper data uri to buffer conversion (#703) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add funding info * fix: Flawed property existence test (#706) Fix a problem where not all prototype methods are copied from the Body via the mixin method due to a failure to properly detect properties in the target. The current code uses the `in` operator, which may return properties lower down the inheritance chain, thus causing them to fail the copy. The new code properly calls the `.hasOwnProperty()` method to make the determination. * fix: Properly handle stream pipeline double-fire Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: Fix spelling Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Add `funding` field to package.json (#708) * Fix: Do not set ContentLength to NaN (#709) * do not set ContentLength to NaN * lint * docs: Add logo Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update repository name from bitinn/node-fetch to node-fetch/node-fetch. Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Fix unit tests Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump @pika/plugin-copy-assets from 0.7.1 to 0.8.1 (#713) Bumps [@pika/plugin-copy-assets](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore(deps): Bump @pika/plugin-build-types from 0.7.1 to 0.8.1 (#710) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump nyc from 14.1.1 to 15.0.0 (#714) Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.0.0. - [Release notes](https://github.com/istanbuljs/nyc/releases) - [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md) - [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * chore: Update travis ci url Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore(deps): Bump mocha from 6.2.2 to 7.0.0 (#711) Bumps [mocha](https://github.com/mochajs/mocha) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v6.2.2...v7.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * feat: Allow excluding a user agent in a fetch request by setting… (#715) Signed-off-by: Richie Bendall <richiebendall@gmail.com> * Bump @pika/plugin-build-node from 0.7.1 to 0.8.1 (#717) Bumps [@pika/plugin-build-node](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.7.1 to 0.8.1 (#716) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.7.1 to 0.8.1. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.7.1...v0.8.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump form-data from 2.5.1 to 3.0.0 (#712) Bumps [form-data](https://github.com/form-data/form-data) from 2.5.1 to 3.0.0. - [Release notes](https://github.com/form-data/form-data/releases) - [Commits](https://github.com/form-data/form-data/compare/v2.5.1...v3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * fix: typo * update suggestion * feat: Added missing redirect function (#718) * added missing redirect function * chore: Add types Co-authored-by: Richie Bendall <richiebendall@gmail.com> * fix: Use req.setTimeout for timeout (#719) * chore: Update typings comment Signed-off-by: Richie Bendall <richiebendall@gmail.com> * chore: Update deps Signed-off-by: Richie Bendall <richiebendall@gmail.com> * docs: center badges & Open Collective button * docs: add missing comma * Remove current stable & LTS node version numbers from the comments I don't think we really want to update them * Bump xo from 0.25.4 to 0.26.1 (#730) Bumps [xo](https://github.com/xojs/xo) from 0.25.4 to 0.26.1. - [Release notes](https://github.com/xojs/xo/releases) - [Commits](https://github.com/xojs/xo/compare/v0.25.4...v0.26.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-build-types from 0.8.3 to 0.9.2 (#729) Bumps [@pika/plugin-build-types](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Bump @pika/plugin-standard-pkg from 0.8.3 to 0.9.2 (#726) Bumps [@pika/plugin-standard-pkg](https://github.com/pikapkg/builders) from 0.8.3 to 0.9.2. - [Release notes](https://github.com/pikapkg/builders/releases) - [Commits](https://github.com/pikapkg/builders/compare/v0.8.3...v0.9.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * docs: Update information about `req.body` type in v3.x release * Add information about removed body type to the v3 upgrade guide * add awesome badge * Show 2 ways of importing node-fetch (CommonJS & ES module) * update dependencies * lint * refactor: Replace `url.parse` with `new URL()` (#701) * chore: replace `url.parse` with `new URL()` * lint * handle relative URLs * Change error message * detect whether the url is absolute or not * update tests * drop relative url support * lint * fix tests * typo * Add information about dropped arbitrary URL support in v3.x upgrade guide * set xo linting rule (node/no-deprecated-api) to on * remove the `utf8` dependency * fix * refactor: split tests into several files, create the `utils` directory * Update package.json scripts & remove unnecessary xo linting rules * refactor: turn on some xo linting rules to improve code quality * fix tests * Remove invalid urls * fix merge conflict * update the upgrade guide * test if URLs are encoded as UTF-8 * update xo to 0.28.0 * chore: Build before publishing * v3.0.0-beta.1 * fix lint on test/main.js Co-authored-by: Richie Bendall <richiebendall@gmail.com> Co-authored-by: Antoni Kepinski <xxczaki@pm.me> Co-authored-by: aeb-sia <50743092+aeb-sia@users.noreply.github.com> Co-authored-by: Nazar Mokrynskyi <nazar@mokrynskyi.com> Co-authored-by: Steve Moser <contact@stevemoser.org> Co-authored-by: Erick Calder <e@arix.com> Co-authored-by: Yaacov Rydzinski <yaacovCR@gmail.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Jimmy Wärting <jimmy@warting.se>
2020-03-13 08:06:25 -07:00
[whatwg-nodejs-url]: https://nodejs.org/api/url.html#url_the_whatwg_url_api
[changelog]: CHANGELOG.md