node.js - 第二次尝试请求失败
问题描述
我有一个应用程序发送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);
解决方案
推荐阅读
- twilio - Twilio 函数 - 同步数据突变
- r - 如何找到R中两个时间戳之间的差异?
- php - PHP计算多维数组中的数组键
- android - 带有 Adview + ToolBar 和 AppBarLayout 的片段中的空白
- visual-studio-2010 - 更改 SSRS 报告和子报告的部署位置
- shell - 匹配后替换字符
- reactjs - react-bootstrap 进度条 - 你能改变标签颜色吗?
- python - 使用 SpaCy 解析句子的更好方法?
- python - 使用 Python (sftp) 更改远程 Linux 系统的密码
- python - Django可以打开图像,但不能将其保存到数据库