`type` as a function
jamesplease opened this issue · 0 comments
jamesplease commented
Many enterprisey APIs don't respect the Accept
header, so even if you specify JSON you may get something else entirely back. i.e.; old Java/Apache web servers frequently return text stack traces for any error.
It's convenient to be able to dynamically specify the type
based on this.
i.e.;
// this API returns stack trace errors ;.;
type(response) {
return response.ok ? 'json' : 'text';
}
Related: #24
(I know I've been opening a million issues. I plan to resolve them! Lots to do...I'll get to it