Created
April 11, 2021 00:29
-
-
Save v9n/087eee1e22438e822835d5cb47ad7e1e to your computer and use it in GitHub Desktop.
hanami webhook demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 4443; | |
app.use(express.json()); //Used to parse JSON bodies | |
// HANAMI added this | |
app.use(express.urlencoded({extended:false})); //Parse URL-encoded bodies | |
app.get('/', (req, res) => { | |
console.log('Hello world, this is a processing test server'); | |
res.send('Request successfully recevied by webhook'); | |
}) | |
app.post('/', (req, res) => { | |
console.log("Request intercepted by Hamani. Request body: ", req.body); | |
// HANAMI added this | |
console.log("YOUR EMAIL is in", JSON.parse(req.body.email)); | |
res.status(200).send('Request successfully recevied by webhook'); | |
}); | |
app.listen(port, () => { | |
console.log(`Example app listening on port ${port}`); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment