@web3forms/react
Version:
Recieve form submissions directly to your inbox without any configuration. Powered by Web3forms. Integrates with react-hook-form and other form libs too!
2 lines (1 loc) • 420 B
JavaScript
export default({access_key:e,settings:s={},onSuccess:t,onError:n})=>({submit:function(o){try{return Promise.resolve(fetch("https://api.web3forms.com/submit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({access_key:e,...s,...o})})).then(function(e){return Promise.resolve(e.json()).then(function(e){!0===e.success?t(e.message,e):n(e.message,e)})})}catch(e){return Promise.reject(e)}}});