UNPKG

@artmate/chat

Version:

**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**

23 lines (22 loc) 724 B
const c = async (i, r = {}) => { const { fetch: n = globalThis.fetch, middlewares: t = {}, ...f } = r; if (typeof n != "function") throw new TypeError("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 TypeError("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 };