我使用viber网站上的示例,但出现此错误。有什么事吗谢谢!
https://developers.viber.com/blog/2017/05/24/test-your-bots-locally
(node:11512) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
<node_internals>/internal/process/warning.js:32
(node:11512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const ngrok = require("./get_public_url");
const ViberBot = require("viber-bot").Bot;
// Creating the bot with access token, name and avatar
const bot = new ViberBot({
authToken: "token",
name: "EchoBot",
avatar: "url",
});
const http = require("http");
const port = process.env.PORT || 8080;
return ngrok.getPublicUrl().then((publicUrl) => {
console.log('Set the new webhook to"', publicUrl);
http
.createServer(bot.middleware())
.listen(port, () => bot.setWebhook(publicUrl));
});
答案 0 :(得分:1)
您需要赶上诺言拒绝,才能了解问题所在:
return ngrok.getPublicUrl().then((publicUrl) => {
console.log('Set the new webhook to"', publicUrl);
http
.createServer(bot.middleware())
.listen(port, () => bot.setWebhook(publicUrl));
}).catch(e => console.error(e));