首页 > 解决方案 > 如何将 WebKitFormBoundary 解析为 netlify 函数?

问题描述

我的问题是我将 FormData 类型的记录发送到我的 netlify 函数。

表格代码:

const onSubmitWithReCAPTCHA = async (e) =>{
   e.preventDefault()
   const action = e.target.action
   const data = new FormData(e.target)
   const token = await 
   recaptchaRef.current.executeAsync()
   data.set("g-recaptcha-response", token)
   fetch(action, {
     method: "post",
     body: data,
   }).then((_response) => {
     return navigate("/")
   })
 }

那是我的 WebKitFormBoundary 到达 netlify 函数:

------WebKitFormBoundaryi7nDDId3RXxrRRso
Content-Disposition: form-data; name="bot-field"
------WebKitFormBoundaryi7nDDId3RXxrRRso
Content-Disposition: form-data; name="form-name"
   newsletter
------WebKitFormBoundaryi7nDDId3RXxrRRso
Content-Disposition: form-data; name="email"
   test@gmail.com
------WebKitFormBoundaryi7nDDId3RXxrRRso
Content-Disposition: form-data; name="g-recaptcha-response"
------WebKitFormBoundaryi7nDDId3RXxrRRso--

如何在 netlify 函数中解析此 WebKitFormBoundary 以将电子邮件提取为字符串?不幸的是,我在互联网上没有找到一个例子……</p>

标签: javascriptnode.jsnetlifynetlify-function

解决方案


推荐阅读