Skip to content

Instantly share code, notes, and snippets.

@gjohnson
Last active December 29, 2015 23:18
Show Gist options
  • Save gjohnson/7741602 to your computer and use it in GitHub Desktop.
Save gjohnson/7741602 to your computer and use it in GitHub Desktop.
superagent2.0 thoughts.

superagent 2.0

Environments

It should officially support node and the browser through component(1). I don't personally want to worry about browserify, but if the desire is strong enough we can do that too.

The main goal here is to leverage component to share more internal code between node and the browser.

Plugins

It should have plugin support via the traditional .use(fn) method. It will be up to the plugin authors to ensure it works in all environments or document it's entended usage.

var request = require('superagent');
var retry = require('superagent-retry');

request
.get('/')
.use(retry(2))
.end(callback);

See: ladjs/superagent#294

Trimming Down

By supporting plugins, it should remove features that were bundled previously and write plugins for them. Including:

  • authentication
  • multipart
  • ????

I think a good candidate for a plugin is a feature that does not work both in node and the browser and also a feature that has it's own level of complexity/options (e.g authentication).

Streaming

It should support streams2 and also keep in mind the browser stream stuff for future's sake.

See: https://github.com/whatwg/streams

Error Handling

It should be a little more straight forward, following @defunctzombie's ideas.

See: ladjs/superagent#283

Reusable Agent

Need to look into all the issues and feature requests for this more...

Promises

Nope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment