Last active
November 18, 2019 04:46
-
-
Save wildan3105/0f9773e77cd7623bfb68a8075c9364d3 to your computer and use it in GitHub Desktop.
simple nodejs script to handle/listen callback
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 bodyParser = require('body-parser'); | |
const app = express(); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ | |
extended: true, | |
})); | |
// assume callback url is: http://localhost:3000/event | |
app.post('/event', (req, res) => { | |
res.send('OK'); | |
// handle the data sent from callback here | |
console.log(req.body) | |
}); | |
const portToListenOn = 3000; | |
app.listen(portToListenOn, () => { | |
console.log(`Listening callback notif on port ${portToListenOn}. Started ${new Date().toString()}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment