UNPKG

@gam-test/fetch-wrapper

Version:

A simple fetch wrapper for better error handling and less response context

2 lines 1.52 kB
import{a as s}from"./chunk-INNHLF44.js";import{a}from"./chunk-Y6M5DMXN.js";import{a as o}from"./chunk-HUE5IG4R.js";import{a as h}from"./chunk-IXKPKR7U.js";import{a as C}from"./chunk-AUTHRURF.js";import{a as r}from"./chunk-CWKM6Z43.js";var d=class{#e;#n;#t;constructor({baseUrl:t,defaultBodyParser:e,config:n}){this.#e=t,this.#n=e,this.#t=n}#r(t){return t?"bodyParser"in t?{...this.#t,...t,bodyParser:t.bodyParser??this.#n,headers:{...this.#t?.headers,...t?.headers}}:{...this.#t,...t,bodyParser:this.#n,headers:{...this.#t?.headers,...t?.headers}}:{...this.#t,bodyParser:this.#n,headers:{...this.#t?.headers}}}#i(t){return t?"bodyParser"in t?{...this.#t,...t,bodyParser:t.bodyParser??this.#n,headers:{...this.#t?.headers,...t?.headers}}:{...this.#t,...t,bodyParser:this.#n,headers:{...this.#t?.headers,...t?.headers}}:{...this.#t,data:null,bodyParser:this.#n,headers:{...this.#t?.headers}}}async get(t,e){let n=new s({url:`${this.#e}${t}`}),i=this.#r(e);return await n.request(i)}async head(t,e){let n=new a({url:`${this.#e}${t}`}),i=this.#r(e);return await n.request({...i,bodyParser:void 0})}async post(t,e){let n=new h({url:`${this.#e}${t}`}),i=this.#i(e);return await n.request(i)}async patch(t,e){let n=new o({url:`${this.#e}${t}`}),i=this.#i(e);return await n.request(i)}async put(t,e){let n=new C({url:`${this.#e}${t}`}),i=this.#i(e);return await n.request(i)}async delete(t,e){let n=new r({url:`${this.#e}${t}`}),i=this.#i(e);return await n.request(i)}};export{d as a}; //# sourceMappingURL=chunk-BPWY4HBD.js.map