0

我正在尝试通过自定义表单将 Webhook 从 WIX 发送到 Zapier。我收到来自 Zapier 的成功消息,他们已收到 webhook,但 webhook 中没有数据可供读取。下面是我的代码,所以如果有人能给我一些提示和技巧,那就太好了!

import {fetch} from 'wix-fetch';


export function button1_click(event,$w){

  const url = "https://hooks.zapier.com/hooks/catch/2560455/a9eoqe/";

 let firstName = $w("#firstName").value;
 let lastName = $w("#lastName").value;
 let contactEmail = $w("#contactEmail").value;
 let contactCompany =$w ("#contactCompany").value;
 let contactNumber = $w("#contactNumber").value;
 let contactStaffN = $w("#contactStaffN").value;
 let contactComments = $w("#contactComments").value;
 let data = {"firstName":firstName, "lastName":lastName, "contactEmail":contactEmail, "contactCompany":contactCompany, "contactNumber":contactNumber, "contactStaffN":contactStaffN, "contactComments":contactComments};
    console.log(data);

    var bodyData = JSON.stringify(data);

    fetch (url, {method: 'post' ,body: 'bodyData'})
    .then((httpResponse)=>{
        if(httpResponse.ok){
            return httpResponse.json();
        }else{
            return Promise.reject("Fetchdidnotsucceed");
        }
    })
    .then(json=>{
        console.log(JSON.stringify(json));
        $w("#button1").disable();
        $w("#button1").label="Thanks for submitting the data!";
    })
    .catch(err=>console.log(err));
}
4

0 回答 0