@estarlincito/utils
Version:
A collection of utility functions designed to simplify and speed up development tasks in JavaScript and TypeScript projects.
2 lines (1 loc) • 549 B
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./handle-error.cjs"),a=t=>{try{const e=JSON.parse(t);return new URLSearchParams(e).toString()}catch{i.handleError("Invalid JSON string in body");return}},s=async({url:t,body:e,headers:r,method:n})=>{const o=t instanceof URL?t.toString():t,c={body:e?a(e):void 0,headers:r??{Accept:"*/*","Content-Type":"application/x-www-form-urlencoded","User-Agent":"Estarlincito (https://www.estarlincito.com)"},method:n};return await fetch(o,c)};exports.apiFetch=s;