Superagent is a lightweight, progressive HTTP request client library designed for both Node.js and browser environments, offering a consistent and fluent API. It is currently at stable version 10.3.0 and exhibits an active development cadence, with frequent patch and minor releases addressing bugs, dependency updates, and minor enhancements. Its key differentiators include a minimal footprint for browser use (approx. 50KB minified and gzipped), a highly chainable request builder API, and robust support for various HTTP features like redirects, retries, and multipart requests. Superagent supports traditional callback-based APIs, Promises for `.then().catch()` patterns, and `async/await` for modern JavaScript concurrency. It serves as a popular alternative to `axios`, `fetch` API (especially in environments requiring broad browser compatibility), or `node-fetch`, providing a unified interface across different JavaScript runtimes.
npm install superagentVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `superagent` with `async/await` for both GET and POST requests, including proper error handling for network and API responses.
Upgrade your Node.js environment to version 14.18.0 or newer. Consider using an LTS version for stability.
Include polyfills such as `https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt` before loading the `superagent` script in your HTML.
In ESM modules, use `import superagent from 'superagent';`. In CommonJS modules, use `const superagent = require('superagent');`. Ensure your project's module configuration (e.g., `package.json` `type: 'module'`) aligns with your chosen import style.Always include error handling. For promises, use `.catch(errorCallback)` or wrap `await` calls in `try...catch`. For callback-based requests, ensure your `end()` function handles the `err` argument.
Upgrade `superagent` to version 10.1.1 or higher. This issue was resolved by a dependency fix in that release.
Change `const superagent = require('superagent');` to `import superagent from 'superagent';`.Update `superagent` to version 10.1.1 or newer to resolve this internal dependency conflict.
Ensure all `superagent` promise chains include a `.catch(errorCallback)` and all `async/await` calls are wrapped in `try...catch` blocks.
No dependency data recorded yet.