wretch
Version:
A tiny wrapper built around fetch with an intuitive syntax.
2 lines • 690 B
JavaScript
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.wretchFormDataAddon=t())})(this,function(){function e(t,n=!1,r=new FormData,i=[]){return Object.entries(t).forEach(([t,a])=>{let o=i.reduce((e,t)=>e?`${e}[${t}]`:t,null);if(o=o?`${o}[${t}]`:t,a instanceof Array||globalThis.FileList&&a instanceof FileList)for(let e of a)r.append(o,e);else n&&typeof a==`object`&&(!(n instanceof Array)||!n.includes(t))?a!==null&&e(a,n,r,[...i,t]):r.append(o,a)}),r}return{wretch:{formData(t,n={}){return this.body(e(t,n.recursive??!1))}}}});
//# sourceMappingURL=formData.min.js.map