UNPKG

ant-design-x-vue

Version:

Craft AI-driven interfaces effortlessly

23 lines (22 loc) 716 B
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; }; export { c as default };