ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
2 lines (1 loc) • 699 B
JavaScript
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=async(i,r={})=>{const{fetch:n=globalThis.fetch,middlewares:t={},...f}=r;if(typeof n!="function")throw new Error("The options.fetch must be a typeof fetch function!");let o=[i,f];typeof t.onRequest=="function"&&(o=await t.onRequest(...o));let e=await n(...o);if(typeof t.onResponse=="function"){const s=await t.onResponse(e);if(!(s instanceof Response))throw new Error("The options.onResponse must return a Response instance!");e=s}if(!e.ok)throw new Error(`Fetch failed with status ${e.status}`);if(!e.body)throw new Error("The response body is empty.");return e};exports.default=c;
;