top of page
bottom of page
import { ok, serverError } from 'wix-http-functions';
export function post_webhook(request) {
// Extract data from the request body
return request.body.text()
.then(body => {
const data = JSON.parse(body); // Parse JSON data
console.log('Received webhook data:', data);
// Optionally send this data to Zapier
return fetch('https://hooks.zapier.com/hooks/catch/21241255/2zk3jow/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
})
.then(() => ok({ body: 'Webhook received and forwarded to Zapier' }))
.catch(error => serverError({ body: 'Error sending data to Zapier' }));
})
.catch(error => serverError({ body: 'Error parsing webhook data' }));
}