-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: implement validateStatus like axios? #19
Comments
i would prefer a property like |
Sorry, I don't follow precisely what you mean. Where would that property be? Also, what do you feel about custom I'm currently using this hack on top of requisition:
|
I think it's just const status = res.statusCode;
this.status =
this.statusCode = status;
this.ok = status >= 200 && status < 300; or memo(Response.prototype, 'ok', function () {
return this.status >= 200 && this.status < 300;
})
this module deps |
Ah, sorry, I don't think the point came across precisely: the idea of the |
Oh, sorry! It's looks like ? const createError = require('http-errors')
const statuses = require('statuses')
...
Response.prototype.checkStatus = function () {
const status = this.status
const ok = status >= 200 && status < 300
if (!ok) {
throw createError(status, statuses[status])
}
...
} |
Yes! But the point of having a user-configured function is that it allows the users of the lib to determine whether they want their promise to fail or not. |
Hi! Have you thought about implementing something like
validateStatus
fromaxios
?https://github.com/mzabriskie/axios#request-config
I could maybe draft a PR if you think this fits the bill.
The text was updated successfully, but these errors were encountered: