-
Notifications
You must be signed in to change notification settings - Fork 317
Change callback API from (err, response, data)
to (err, data)
#86
Conversation
- Better standardize callback format to accept two parameters, `error` and `data`. (BREAKING CHANGE) - Switch from `request` to `superagent` library - Add client-side handling of throttling requests within rate limits (via [`superagent-throttle`](https://github.com/leviwheatcroft/superagent-throttle) plugin) - Refactor tests to use new two-parameter API and to use mocha's promise API where possible (instead of manually using (`done`) method) - Bump version in `package.json` to reflect breaking API change
to be more idiomatic with how these "options" are discussed. - Reduce ambiguity with function arguments; options are given as properties on an object which *is an argument itself* - Intended to help users looking at the source for the first time; will also benefit with future auto-generated docs, etc.
Implementation also lays foundation for more static methods
…brary's `DEFAULT_BOOK_LEVEL`
If a different gdax api URI is desired, the user should provide an instance of a client that has its `apiURI` set BREAKING CHANGE
and bypass adding throttling plugin at all, e.g. `rateLimit: false`. This is potentially more intuitive than setting `rateLimit: Infinity` (which still works though).
Why not make |
I agree that this would make the callback interface more consistent with the promise interface , but the problem is that we have to consider backwards compatibility. I'd be more in favor of changing the promise signature to resolve with a Pros/Cons: exposing the raw In truth, the best approach would be to return a reformatted, simpler {
statusCode,
statusMessage,
headers,
body,
data, // JSON parsed version of body
} By keeping the Steps I'd like to see:
|
I rebased this, which should have broken a bunch of stuff. In general there are a bunch of changes here that I'd love to land (the entire request refactor, including throttling, is 💯), but the callback interface should probably stay the same for now. Instead, I'd opt for deprecating the callback interface entirely and urging all users to use promises. @rmm5t's point is very valid. At some point I'd love to switch large parts of this library to something generated from a Swagger config, having an interface in place that would allow an easy transition would be ideal. That also means we have to map superagent objects. For me this is the last change I'd like to see land before we can publish a 1.0. |
I'll work on introducing the request and throttling features based on the most recent master. I agree that the callback interface is best left alone for now. |
@nikulis Great to see you back :D Lmk if there is anything that can be done to help you! |
error
anddata
. (BREAKING CHANGE)request
tosuperagent
librarysuperagent-throttle
plugin)API where possible (instead of manually using (
done
) method)package.json
to reflect breaking API change