formspree's notebooks

  • Formspree Webhook Example - /formspree/formspree-webhook-example
    Last edited 9 months ago
    require("isomorphic-fetch") exports.endpoint = function(req, res) { let url = req.url; if (url === '/hook') { let hook_secret = req.headers["x-hook-secret"] if (hook_secret) { // Step 1: Confirm the subscription this request // includes an X-Hook-Secret res.setHeader("x-hook-secret", hook_secret) res.end(); } else { // Step 2: Receive webhook requests! console.log("Received webhook! Now do something!") res.end() } } else { res.end(url + "\n"); } }