A NodeJS simplified version of SuperAgent.js for making JSON HTTP requests.
Superagent is great! It lets you structure your requests cleanly and programmatically.
But it's also pretty heavy - it contains lots of features that aren't necessary for making simple JSON requests, which are most of the requests I make most of the time. If I'm bundling up a small Lambda function, it's better to have a super small library to provide the same functionality without all the extra stuff.
- Can probably do most of what you need for API requests
- Has no production dependencies
- Is small: roughly 100 lines of code
- Is typed with Typescript
- Has good test coverage
$ npm install --save simpleragent
Basic JSON requests work just fine:
const request = ;// Auth and query stringsrequest;// Promises, within an async functionconst resp = await request;// Sending JSON bodies, HTTPS, and setting headersrequest;
What Isn't Supported?
Features that are left out:
- Content-Types besides JSON: no
- Piping response data: Data loaded directly into memory
- Sessions: Cookies not saved
- Progress Tracking: Don't use it for big uploads
- Browser version: Node only
- Retrying request: Do that manually if you want it
- TLS options: Maybe will add these later
- Aborts / Timeouts
- Following Redirects
- Plugins, etc.