Open chrissnyder opened 9 years ago
I think this'd be cool :+1: , definitely better than lacing that logic into the lib
Does superagent not handle this automatically?
Sort of, but not quite.
For example, only on node does it expose the agent function, which gives you a cookie jar to maintain a session, re: https://github.com/zooniverse/json-api-client/blob/master/src/make-http-request.coffee#L7
Inversely, only in the browser does it give you access to withCredentials, re: https://github.com/zooniverse/json-api-client/blob/master/src/make-http-request.coffee#L31
Another problem I ran into is that when you use the agent function, it only aliases the the http verb functions back, so it throws when I try to set a custom parser https://github.com/zooniverse/json-api-client/blob/master/src/make-http-request.coffee#L11.
In short, I was running into enough minor issues where I figured I'd throw this out there. I don't think any of these issues can't be worked through, but wanted to get feelings on whether an explicit separation would be smarter than implicitly changing how the file acts based upon environment.
Anyone have thoughts on using https://github.com/substack/node-browserify#browser-field to make separate browser/node specific files here?
I'm running into a fair number of issues in https://github.com/zooniverse/panoptes-javascript-client/tree/refactor trying to work around different behavior, both intrinsic in browser/node environments, and in how superagent works differently in each.
Tagging @aweiksnar @rogerhutchings @brian-c