Gathering detailed insights and metrics for superagent
Gathering detailed insights and metrics for superagent
Gathering detailed insights and metrics for superagent
Gathering detailed insights and metrics for superagent
Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
npm install superagent
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
16,593 Stars
1,921 Commits
1,329 Forks
224 Watching
2 Branches
265 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
JavaScript (88.28%)
HTML (11.21%)
Makefile (0.47%)
Shell (0.04%)
Cumulative downloads
Total Downloads
Last day
-7.6%
1,873,158
Compared to previous day
Last week
2.8%
10,900,937
Compared to previous week
Last month
11%
44,709,567
Compared to previous month
Last year
9.6%
460,891,262
Compared to previous year
36
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 and Lad.
npm:
1npm install superagent
yarn:
1yarn add superagent
1const superagent = require('superagent'); 2 3// callback 4superagent 5 .post('/api/pet') 6 .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body 7 .set('X-API-Key', 'foobar') 8 .set('accept', 'json') 9 .end((err, res) => { 10 // Calling the end function will send the request 11 }); 12 13// promise with then/catch 14superagent.post('/api/pet').then(console.log).catch(console.error); 15 16// promise with async/await 17(async () => { 18 try { 19 const res = await superagent.post('/api/pet'); 20 console.log(res); 21 } catch (err) { 22 console.error(err); 23 } 24})();
The browser-ready, minified version of superagent
is only 50 KB (minified and gzipped).
Browser-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.
Note that we also provide unminified versions with
.js
instead of.min.js
file extensions.
This is the solution for you if you're just using <script>
tags everywhere!
1<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt"></script> 2<script src="https://cdn.jsdelivr.net/npm/superagent"></script> 3<!-- if you wish to use unpkg.com instead: --> 4<!-- <script src="https://unpkg.com/superagent"></script> --> 5<script type="text/javascript"> 6 (function() { 7 // superagent is exposed as `window.superagent` 8 // if you wish to use "request" instead please 9 // uncomment the following line of code: 10 // `window.request = superagent;` 11 superagent 12 .post('/api/pet') 13 .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body 14 .set('X-API-Key', 'foobar') 15 .set('accept', 'json') 16 .end(function (err, res) { 17 // Calling the end function will send the request 18 }); 19 })(); 20</script>
If you are using browserify, webpack, rollup, or another bundler, then you can follow the same usage as Node above.
Node: v14.18.0+
Browsers (see .browserslistrc):
1npx browserslist
1and_chr 102 2and_ff 101 3and_qq 10.4 4and_uc 12.12 5android 101 6chrome 103 7chrome 102 8chrome 101 9chrome 100 10edge 103 11edge 102 12edge 101 13firefox 101 14firefox 100 15firefox 91 16ios_saf 15.5 17ios_saf 15.4 18ios_saf 15.2-15.3 19ios_saf 15.0-15.1 20ios_saf 14.5-14.8 21ios_saf 14.0-14.4 22ios_saf 12.2-12.5 23kaios 2.5 24op_mini all 25op_mob 64 26opera 86 27opera 85 28safari 15.5 29safari 15.4 30samsung 17.0 31samsung 16.0
We recommend using https://cdnjs.cloudflare.com/polyfill/ (specifically with the bundle mentioned in VanillaJS above):
1<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
SuperAgent is easily extended via plugins.
1const nocache = require('superagent-no-cache'); 2const superagent = require('superagent'); 3const prefix = require('superagent-prefix')('/static'); 4 5superagent 6 .get('/some-url') 7 .query({ action: 'edit', city: 'London' }) // query string 8 .use(prefix) // Prefixes *only* this request 9 .use(nocache) // Prevents caching of *only* this request 10 .end((err, res) => { 11 // Do something 12 });
Existing plugins:
res.$
for HTML and XML response bodies.Please prefix your plugin with superagent-*
so that it can easily be found by others.
For SuperAgent extensions such as couchdb and oauth visit the wiki.
Please see GitHub releases page for the current changelog.
Our breaking changes are mostly in rarely used functionality and from stricter error handling.
application/x-www-form-urlencoded
, using arrayFormat: 'indices'
semantics of qs
library. (See: https://www.npmjs.com/package/qs#stringifying)tinyify
and the latest version of Babel using @babel/preset-env
and .browserslistrc
)caniuse-lite
and eslint-plugin-compat
.babelrc
.end()
callbacks to .then()
or await
..send()
multiple times. Invalid calls to .send()
will now throw instead of sending garbage..parse()
in the browser version, rename it to .serialize()
.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)..then()
in Internet Explorer, ensure that you have a polyfill that adds a global Promise
object..end(function(res){})
use .then(res => {})
.Name |
---|
Kornel Lesiński |
Peter Lyons |
Hunter Loftis |
Nick Baugh |
MIT © TJ Holowaychuk
The latest stable version of the package.
Stable Version
1
5.9/10
Summary
superagent vulnerable to zip bomb attacks
Affected Versions
< 3.7.0
Patched Versions
3.7.0
No security vulnerabilities found.