Closed evanshortiss closed 4 years ago
This is a really good idea!
If you or someone else wants to start working on a proof of concept for it let me know, otherwise I'll give it a go when work gives me some free time 😄
Let's continue this in #105, I'll implement the changes to the library this week and then we can discuss them and refine.
I've used this wrapper to perform some simple interactions with the Robinhood API and have a few things on a wishlist that would improve developer experience (IMO). These changes would mean a breaking 2.0 change so it's not a small piece of work, but I'd like to hear your thoughts.
Response Structure
Presently, the library uses
request
format callbacks because under the covers it's wrapping using therequest
module. That means I need to checkres.statusCode
andbody
in my callback.It would be great if the library instead gave me just what I want - the response body JSON or a structured error like this
This would work great with TypeScript since each response type could be defined for code completion and documentation and you'd also be able to declare robinhood types elsewhere as arguments throughout your code, like so:
Promise Support
Having promise support would be great.
Along with the usual Promise benefits, it would allow using async/await for cleaner code in newer node versions:
Refined Error Checks
Currently all error handling is deferred to the developer, i.e I, as a developer, always need to check status codes but the library could easily do this:
It would be great instead if the library checked the status code for me:
We could extend it so specific error classes are used so developers can identify errors easily: