Skip to content

Instantly share code, notes, and snippets.

@wildan3105
Last active November 18, 2019 04:46
Show Gist options
  • Save wildan3105/0f9773e77cd7623bfb68a8075c9364d3 to your computer and use it in GitHub Desktop.
Save wildan3105/0f9773e77cd7623bfb68a8075c9364d3 to your computer and use it in GitHub Desktop.
simple nodejs script to handle/listen callback
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