首页 > 解决方案 > 第二次尝试请求失败

问题描述

我有一个应用程序发送POST请求并等待一定时间,直到它从电报机器人 API 收到消息,我正在使用Telegraf库与电报机器人 API 进行交互。它在第一次请求时工作正常,但我得到Cannot set headers after they are sent to the client错误,甚至没有第二次将任何内容发送回服务器。这是代码的样子......

const router = require("express").Router();
const bot = require("./config/bot");

router.post("/", (req, res) => {
    // if it doesn't get message back within 5min it'll close the request
    req.setTimeout(300000);

    bot.command("start", (ctx) => {
        let text = ctx.message.text;
        res.send(text);
    });
});

app.listen(3000);

标签: node.jsexpresstelegram-bottelegraf

解决方案


推荐阅读