{"id":10392,"library":"got","title":"Got HTTP Client","description":"Got is a human-friendly and powerful HTTP request library for Node.js, currently at v15.0.2. It provides a modern Promise-based API for making HTTP requests, including features like retry mechanisms, hooks, and stream support. The library is actively maintained with frequent patch releases and major version updates that may introduce breaking changes, notably requiring Node.js 22+ and being ESM-only since v12 (reiterated in v15).","status":"active","version":"15.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/got","tags":["javascript","http","https","http2","get","got","url","uri","request"],"install":[{"cmd":"npm install got","lang":"bash","label":"npm"},{"cmd":"yarn add got","lang":"bash","label":"yarn"},{"cmd":"pnpm add got","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Got is native ESM. CommonJS `require()` is not supported.","wrong":"const got = require('got');","symbol":"got","correct":"import got from 'got';"}],"quickstart":{"code":"import got from 'got';\n\n(async () => {\n  try {\n    const { data } = await got.post('https://httpbin.org/anything', {\n      json: {\n        hello: 'world'\n      }\n    }).json();\n\n    console.log('Response data:', data);\n    // Expected output: { \"hello\": \"world\" }\n  } catch (error) {\n    console.error('Request failed:', error);\n  }\n})();","lang":"typescript","description":"Demonstrates making a POST request with a JSON payload and receiving a JSON response using Got's dedicated JSON mode."},"warnings":[{"fix":"Upgrade your Node.js runtime to version 22 or newer.","message":"Got v15.0.0 and later require Node.js 22 or higher.","severity":"breaking","affected_versions":">=15.0.0"},{"fix":"Use the standard `AbortController` and the `signal` option for request cancellation. For example: `const controller = new AbortController(); got('url', { signal: controller.signal }); controller.abort();`","message":"The `promise.cancel()` API was removed in v15.0.0.","severity":"breaking","affected_versions":">=15.0.0"},{"fix":"Use `got.stream()` directly for streaming requests instead of the `isStream` option.","message":"The `isStream` option has been removed in v15.0.0.","severity":"breaking","affected_versions":">=15.0.0"},{"fix":"Ensure your project is configured for ESM, or use dynamic `import()` if you cannot fully convert to ESM. For example: `const got = await import('got');`","message":"Got is a native ESM package and does not provide a CommonJS export. Attempting to `require()` it will result in an error.","severity":"gotcha","affected_versions":">=12.0.0"},{"fix":"Evaluate if `Ky` or `fetch-extras` better fit your project's requirements, especially if you need browser support or a lighter-weight API.","message":"The `got` maintainers recommend considering `Ky` (for browser compatibility, smaller size, Fetch API base) or `fetch-extras` (for simpler needs) as alternatives.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Refactor your cancellation logic to use `AbortController` and the `signal` option: `const controller = new AbortController(); got('url', { signal: controller.signal }); controller.abort();`","cause":"Attempting to call the `cancel()` method on a `got` promise, which was removed in v15.0.0.","error":"TypeError: promise.cancel is not a function"},{"fix":"Convert your project or the specific file to use ES modules (`import`). Alternatively, use dynamic import: `const got = await import('got');`","cause":"Trying to import `got` using `require()` in a CommonJS module, but `got` is an ESM-only package.","error":"TypeError [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/got/dist/index.js from ... not supported."},{"fix":"Upgrade `got` to version 14.6.6 or higher to resolve the stream auto-end issue for PATCH/DELETE/OPTIONS methods.","cause":"A bug in `got` versions 14.6.0 to 14.6.5 incorrectly auto-closed streams for empty PATCH/DELETE/OPTIONS requests, preventing data from being piped to them.","error":"write after end"},{"fix":"Remove the `isStream` option. Instead, use `got.stream()` directly for all streaming use cases.","cause":"Using the `isStream` option with a boolean value in `got` v15.0.0+, where this option has been removed.","error":"TypeError: Argument for option 'isStream' must be a boolean"}],"ecosystem":"npm"}