@webreflection/fetch
Version:
A fetch with Response abilities.
2 lines (1 loc) • 391 B
JavaScript
const e=Object.getOwnPropertyDescriptors(Response.prototype),t=e=>"function"==typeof e,o={get:(o,r)=>e.hasOwnProperty(r)?((e,o,{get:r,value:n})=>r||!t(n)?e.then(e=>e[o]):(...t)=>e.then(e=>e[o](...t)))(o,r,e[r]):((e,o)=>t(o)?o.bind(e):o)(o,o[r])};var r=(e,...t)=>new Proxy(fetch(e,...t).then(t=>t.ok?t:Promise.reject(new Error(`[${t.status}] Unable to fetch ${e}`))),o);export{r as default};