{"id":27006689,"url":"https://github.com/visionmedia/superagent","last_synced_at":"2025-04-04T08:01:37.295Z","repository":{"id":38054912,"uuid":"1607357","full_name":"ladjs/superagent","owner":"ladjs","description":"Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.","archived":false,"fork":false,"pushed_at":"2025-03-11T23:03:30.000Z","size":6420,"stargazers_count":16608,"open_issues_count":179,"forks_count":1325,"subscribers_count":223,"default_branch":"master","last_synced_at":"2025-03-29T21:00:38.785Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ladjs.github.io/superagent/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ladjs.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-04-13T02:29:45.000Z","updated_at":"2025-03-29T15:44:37.000Z","dependencies_parsed_at":"2023-02-14T12:02:48.675Z","dependency_job_id":"5bd488dd-2c47-4edd-87bc-6c452fcf4709","html_url":"https://github.com/ladjs/superagent","commit_stats":{"total_commits":1541,"total_committers":287,"mean_commits":5.369337979094077,"dds":0.7475665152498377,"last_synced_commit":"378f5479ffbad4b4f533b2d7a55e356ada950970"},"previous_names":["visionmedia/superagent"],"tags_count":170,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fsuperagent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fsuperagent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fsuperagent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fsuperagent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladjs","download_url":"https://codeload.github.com/ladjs/superagent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142052,"owners_count":20890652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-04T08:01:12.809Z","updated_at":"2025-04-04T08:01:37.285Z","avatar_url":"https://github.com/ladjs.png","language":"JavaScript","readme":"# superagent\n\n[![build status](https://img.shields.io/travis/ladjs/superagent.svg)](https://travis-ci.org/ladjs/superagent)\n[![code coverage](https://img.shields.io/codecov/c/github/ladjs/superagent.svg)](https://codecov.io/gh/ladjs/superagent)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)\n[![license](https://img.shields.io/github/license/ladjs/superagent.svg)](LICENSE)\n\n\u003e Small progressive client-side HTTP request library, and Node.js module with the same API, supporting many high-level HTTP client features.  Maintained for [Forward Email](https://github.com/forwardemail) and [Lad](https://github.com/ladjs).\n\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n  * [Node](#node)\n  * [Browser](#browser)\n* [Supported Platforms](#supported-platforms)\n  * [Required Browser Features](#required-browser-features)\n* [Plugins](#plugins)\n* [Upgrading from previous versions](#upgrading-from-previous-versions)\n* [Contributors](#contributors)\n* [License](#license)\n\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install superagent\n```\n\n[yarn][]:\n\n```sh\nyarn add superagent\n```\n\n\n## Usage\n\n### Node\n\n```js\nconst superagent = require('superagent');\n\n// callback\nsuperagent\n  .post('/api/pet')\n  .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body\n  .set('X-API-Key', 'foobar')\n  .set('accept', 'json')\n  .end((err, res) =\u003e {\n    // Calling the end function will send the request\n  });\n\n// promise with then/catch\nsuperagent.post('/api/pet').then(console.log).catch(console.error);\n\n// promise with async/await\n(async () =\u003e {\n  try {\n    const res = await superagent.post('/api/pet');\n    console.log(res);\n  } catch (err) {\n    console.error(err);\n  }\n})();\n```\n\n### Browser\n\n**The browser-ready, minified version of `superagent` is only 50 KB (minified and gzipped).**\n\nBrowser-ready versions of this module are available via [jsdelivr][], [unpkg][], and also in the `node_modules/superagent/dist` folder in downloads of the `superagent` package.\n\n\u003e Note that we also provide unminified versions with `.js` instead of `.min.js` file extensions.\n\n#### VanillaJS\n\nThis is the solution for you if you're just using `\u003cscript\u003e` tags everywhere!\n\n```html\n\u003cscript src=\"https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/superagent\"\u003e\u003c/script\u003e\n\u003c!-- if you wish to use unpkg.com instead: --\u003e\n\u003c!-- \u003cscript src=\"https://unpkg.com/superagent\"\u003e\u003c/script\u003e --\u003e\n\u003cscript type=\"text/javascript\"\u003e\n  (function() {\n    // superagent is exposed as `window.superagent`\n    // if you wish to use \"request\" instead please\n    // uncomment the following line of code:\n    // `window.request = superagent;`\n    superagent\n      .post('/api/pet')\n      .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body\n      .set('X-API-Key', 'foobar')\n      .set('accept', 'json')\n      .end(function (err, res) {\n        // Calling the end function will send the request\n      });\n  })();\n\u003c/script\u003e\n```\n\n#### Bundler\n\nIf you are using [browserify][], [webpack][], [rollup][], or another bundler, then you can follow the same usage as [Node](#node) above.\n\n\n## Supported Platforms\n\n* Node: v14.18.0+\n* Browsers (see [.browserslistrc](.browserslistrc)):\n\n  ```sh\n  npx browserslist\n  ```\n\n  ```sh\n  and_chr 102\n  and_ff 101\n  and_qq 10.4\n  and_uc 12.12\n  android 101\n  chrome 103\n  chrome 102\n  chrome 101\n  chrome 100\n  edge 103\n  edge 102\n  edge 101\n  firefox 101\n  firefox 100\n  firefox 91\n  ios_saf 15.5\n  ios_saf 15.4\n  ios_saf 15.2-15.3\n  ios_saf 15.0-15.1\n  ios_saf 14.5-14.8\n  ios_saf 14.0-14.4\n  ios_saf 12.2-12.5\n  kaios 2.5\n  op_mini all\n  op_mob 64\n  opera 86\n  opera 85\n  safari 15.5\n  safari 15.4\n  samsung 17.0\n  samsung 16.0\n  ```\n\n### Required Browser Features\n\nWe recommend using \u003chttps://cdnjs.cloudflare.com/polyfill/\u003e (specifically with the bundle mentioned in [VanillaJS](#vanillajs) above):\n\n```html\n\u003cscript src=\"https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt\"\u003e\u003c/script\u003e\n```\n\n* WeakRef is not supported in Opera 85, iOS Safari 12.2-12.5\n* BigInt is not supported in iOS Safari 12.2-12.5\n\n\n## Plugins\n\nSuperAgent is easily extended via plugins.\n\n```js\nconst nocache = require('superagent-no-cache');\nconst superagent = require('superagent');\nconst prefix = require('superagent-prefix')('/static');\n\nsuperagent\n  .get('/some-url')\n  .query({ action: 'edit', city: 'London' }) // query string\n  .use(prefix) // Prefixes *only* this request\n  .use(nocache) // Prevents caching of *only* this request\n  .end((err, res) =\u003e {\n    // Do something\n  });\n```\n\nExisting plugins:\n\n* [superagent-no-cache](https://github.com/johntron/superagent-no-cache) - prevents caching by including Cache-Control header\n* [superagent-prefix](https://github.com/johntron/superagent-prefix) - prefixes absolute URLs (useful in test environment)\n* [superagent-suffix](https://github.com/timneutkens1/superagent-suffix) - suffix URLs with a given path\n* [superagent-mock](https://github.com/M6Web/superagent-mock) - simulate HTTP calls by returning data fixtures based on the requested URL\n* [superagent-mocker](https://github.com/shuvalov-anton/superagent-mocker) — simulate REST API\n* [superagent-cache](https://github.com/jpodwys/superagent-cache) - A global SuperAgent patch with built-in, flexible caching\n* [superagent-cache-plugin](https://github.com/jpodwys/superagent-cache-plugin) - A SuperAgent plugin with built-in, flexible caching\n* [superagent-jsonapify](https://github.com/alex94puchades/superagent-jsonapify) - A lightweight [json-api](http://jsonapi.org/format/) client addon for superagent\n* [superagent-serializer](https://github.com/zzarcon/superagent-serializer) - Converts server payload into different cases\n* [superagent-httpbackend](https://www.npmjs.com/package/superagent-httpbackend) - stub out requests using AngularJS' $httpBackend syntax\n* [superagent-throttle](https://github.com/leviwheatcroft/superagent-throttle) - queues and intelligently throttles requests\n* [superagent-charset](https://github.com/magicdawn/superagent-charset) - add charset support for node's SuperAgent\n* [superagent-verbose-errors](https://github.com/jcoreio/superagent-verbose-errors) - include response body in error messages for failed requests\n* [superagent-declare](https://github.com/damoclark/superagent-declare) - A simple [declarative](https://en.wikipedia.org/wiki/Declarative_programming) API for SuperAgent\n* [superagent-node-http-timings](https://github.com/webuniverseio/superagent-node-http-timings) - measure http timings in node.js\n* [superagent-cheerio](https://github.com/mmmmmrob/superagent-cheerio) - add [cheerio](https://www.npmjs.com/package/cheerio) to your response content automatically. Adds `res.$` for HTML and XML response bodies.\n* [@certible/superagent-aws-sign](https://github.com/certible/superagent-aws-sign) - Sign AWS endpoint requests, it uses the aws4 to authenticate the SuperAgent requests\n\nPlease prefix your plugin with `superagent-*` so that it can easily be found by others.\n\nFor SuperAgent extensions such as couchdb and oauth visit the [wiki](https://github.com/ladjs/superagent/wiki).\n\n\n## Upgrading from previous versions\n\nPlease see [GitHub releases page](https://github.com/ladjs/superagent/releases) for the current changelog.\n\nOur breaking changes are mostly in rarely used functionality and from stricter error handling.\n\n* [6.0 to 6.1](https://github.com/ladjs/superagent/releases/tag/v6.1.0)\n  * Browser behaviour changed to match Node when serializing `application/x-www-form-urlencoded`, using `arrayFormat: 'indices'` semantics of `qs` library. (See: \u003chttps://www.npmjs.com/package/qs#stringifying\u003e)\n* [5.x to 6.x](https://github.com/ladjs/superagent/releases/tag/v6.0.0):\n  * Retry behavior is still opt-in, however we now have a more fine-grained list of status codes and error codes that we retry against (see updated docs)\n  * A specific issue with Content-Type matching not being case-insensitive is fixed\n  * Set is now required for IE 9, see [Required Browser Features](#required-browser-features) for more insight\n* [4.x to 5.x](https://github.com/ladjs/superagent/releases/tag/v5.0.0):\n  * We've implemented the build setup of [Lass](https://lass.js.org) to simplify our stack and linting\n  * Unminified browserified build size has been reduced from 48KB to 20KB (via `tinyify` and the latest version of Babel using `@babel/preset-env` and `.browserslistrc`)\n  * Linting support has been added using `caniuse-lite` and `eslint-plugin-compat`\n  * We can now target what versions of Node we wish to support more easily using `.babelrc`\n* [3.x to 4.x](https://github.com/ladjs/superagent/releases/tag/v4.0.0-alpha.1):\n  * Ensure you're running Node 6 or later. We've dropped support for Node 4.\n  * We've started using ES6 and for compatibility with Internet Explorer you may need to use Babel.\n  * We suggest migrating from `.end()` callbacks to `.then()` or `await`.\n* [2.x to 3.x](https://github.com/ladjs/superagent/releases/tag/v3.0.0):\n  * Ensure you're running Node 4 or later. We've dropped support for Node 0.x.\n  * Test code that calls `.send()` multiple times. Invalid calls to `.send()` will now throw instead of sending garbage.\n* [1.x to 2.x](https://github.com/ladjs/superagent/releases/tag/v2.0.0):\n  * If you use `.parse()` in the *browser* version, rename it to `.serialize()`.\n  * If you rely on `undefined` in query-string values being sent literally as the text \"undefined\", switch to checking for missing value instead. `?key=undefined` is now `?key` (without a value).\n  * If you use `.then()` in Internet Explorer, ensure that you have a polyfill that adds a global `Promise` object.\n* 0.x to 1.x:\n  * Instead of 1-argument callback `.end(function(res){})` use `.then(res =\u003e {})`.\n\n\n## Contributors\n\n| Name                |\n| ------------------- |\n| **Kornel Lesiński** |\n| **Peter Lyons**     |\n| **Hunter Loftis**   |\n| **Nick Baugh**      |\n\n\n## License\n\n[MIT](LICENSE) © TJ Holowaychuk\n\n\n##\n\n[npm]: https://www.npmjs.com/\n\n[yarn]: https://yarnpkg.com/\n\n[jsdelivr]: https://www.jsdelivr.com/\n\n[unpkg]: https://unpkg.com/\n\n[browserify]: https://github.com/browserify/browserify\n\n[webpack]: https://github.com/webpack/webpack\n\n[rollup]: https://github.com/rollup/rollup\n","funding_links":[],"categories":["Packages","包","Awesome node-modules list","JavaScript","Repository","书签","24. Ajax模块","Web Development","HTTP","目录","Uncategorized","24. 前后端交互","Web 后端","Programming Languages","1. 后端开发"],"sub_categories":["HTTP","13.20 视差滚动(Parallax Scrolling) ###","Angular","React Components","Uncategorized","24.1 Ajax模块","JavaScript","1.1 HTTP"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisionmedia%2Fsuperagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvisionmedia%2Fsuperagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisionmedia%2Fsuperagent/lists"}