@formspark/use-formspark
Version:
React hooks for Formspark
3 lines (2 loc) • 591 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0}),require("whatwg-fetch");var t=require("react");exports.useFormspark=function(e){var n=t.useState(!1),r=n[1];return[function(t){return new Promise((function(n,o){var i="https://submit-form.com/"+e.formId,c=JSON.stringify(t);r(!0),fetch(i,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:c}).then((function(t){return t.json()})).then((function(t){n(t)})).catch((function(t){o(t)})).finally((function(){r(!1)}))}))},n[0]]};
//# sourceMappingURL=use-formspark.cjs.production.min.js.map
;