-
-
Notifications
You must be signed in to change notification settings - Fork 833
Throw errors on !==200 status codes from RTS #662
Conversation
src/RtsClient.js
Outdated
@@ -1,5 +1,25 @@ | |||
const q = require('q'); | |||
const request = q.nfbind(require('browser-request')); | |||
const request = (opts) => { | |||
const expectingJSONOnSucess = opts.json; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
success
src/RtsClient.js
Outdated
|
||
return [response, body]; | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I'm not super keen on making request
be something that is a wrapper around browser-request with more functionality, so I'd say if you're making it behave different on non 2xx responses, that should be a separate function. (Also why does it needs to explicitly parse the json? Doesn't passing the json
flag through to request do that?)
We're gaining a bit of a collection of parts of react sdk doing requests in slightly different ways (DuckDuckGoProvider.js, MFileBody.js, DecryptFile.js and now here). We should try &make them roughly similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IRL: decision is to use fetch
because there's no reason not to
return '?' + Object.keys(params).map((k) => { | ||
return k + '=' + encodeURIComponent(params[k]); | ||
}).join('&'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, forgot fetch doesn't do this for you :/
No description provided.