I am receiving a webhook from patreon, and when I fire the test, I get this error:
(node:636) UnhandledPromiseRejectionWarning: ReferenceError: event is not defined
This is the code I have
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.post('/', async (req, res) => {
let crypto = require('crypto');
let hash = event.headers['X-Patreon-Signature'],
hmac = crypto.createHmac("md5", 'patreon-secret-removed ;)');
hmac.update(event.body);
let crypted = hmac.digest("hex");
if (crypted === hash) {
console.log("That's good hash! " + hash);
} else {
console.log("Bad hash! " + hash + " crypted " + crypted);
}
})
app.listen(8080)
How would I replace event or define it?
let hash = event.headers['X-Patreon-Signature'] << what is event?
Maybe it's a req, not an event.