UNPKG

1.18 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.unfetch=t()}(this,function(){return"function"==typeof fetch?fetch:function(e,t){return t=t||{},new Promise(function(n,o){function r(){var e,t=[],n=[],o={};return s.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(r,s,u){t.push(s=s.toLowerCase()),n.push([s,u]),e=o[s],o[s]=e?e+","+u:u}),{ok:1==(s.status/200|0),status:s.status,statusText:s.statusText,url:s.responseURL,clone:r,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},xml:function(){return Promise.resolve(s.responseXML)},blob:function(){return Promise.resolve(new Blob([s.response]))},headers:{keys:function(){return t},entries:function(){return n},get:function(e){return o[e.toLowerCase()]},has:function(e){return e.toLowerCase()in o}}}}var s=new XMLHttpRequest;s.open(t.method||"get",e);for(var u in t.headers)s.setRequestHeader(u,t.headers[u]);s.withCredentials="omit"!=t.credentials,s.onload=function(){n(r())},s.onerror=o,s.send(t.body)})}});
2//# sourceMappingURL=unfetch.umd.js.map
\No newline at end of file