@whizzes/linx
Version:
API Client for Linx
3 lines (2 loc) • 651 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});class o extends Error{statusCode;constructor(t,r){super(t),this.name=" APIError",this.statusCode=r}}const u={"content-type":"application/json"};class h{prefixUrl;constructor(t){this.prefixUrl=t}async new(t){return new URL(t),await this.post("new",{url:t})}uri(t){return`${this.prefixUrl.toString()}${t}`}async post(t,r,e={}){const a={...e,headers:{...u,...e.headers},method:"POST",body:JSON.stringify(r)},s=await fetch(this.uri(t),a),n=await s.json();if(s.ok)return n;const c=n?.message;throw new o(c,s.status)}}exports.APIError=o,exports.Client=h;
//# sourceMappingURL=index.js.map