-2

我收到来自 patreon 的 webhook,当我启动测试时,我收到此错误:

(node:636) UnhandledPromiseRejectionWarning: ReferenceError: event is not defined

这是我的代码

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)

我将如何替换事件或定义它?

4

1 回答 1

2

let hash = event.headers['X-Patreon-Signature'] << 什么是事件?

也许这是一个请求,而不是一个事件。

于 2021-09-24T04:41:49.580 回答