UNPKG

@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) 588 B
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).react=t()}(this,function(){return({access_key:e,settings:t={},onSuccess:n,onError:s})=>({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,...t,...o})})).then(function(e){return Promise.resolve(e.json()).then(function(e){!0===e.success?n(e.message,e):s(e.message,e)})})}catch(e){return Promise.reject(e)}}})});