我正在尝试创建一个 kik 机器人,但每当我尝试运行它时,我都会收到此错误“ Uncaught ReferenceError :请求未定义”。我已经安装了 Node 和 kik 包,但我的 Javascript 似乎不起作用:
request.post({
url: "https://api.kik.com/v1/config",
auth: {
user: "<my-user-name>",
pass: "<my-api-key>"
},
json: {
"webhook": "<link>",
"features": {
"receiveReadReceipts": false,
"receiveIsTyping": false,
"manuallySendReadReceipts": false,
"receiveDeliveryReceipts": false
},
"staticKeyboard": {
"type": "suggested",
"responses": [
{
"body": "Start",
"type": "text"
},
{
"body": "Help",
"type": "text"
}
]
}
}
}, callback);
我一直在尝试调查这个问题,但一无所获。难道是 Node 问题?
提前谢谢您!!
最佳答案
From the conversation we had, I thought I put the answer here for future references.
这段代码应该在 NodeJS 上以命令行方式运行,而不是在浏览器中运行。
您需要设置一个 Node 环境,使用 npm 或任何您喜欢的方式安装所需的依赖项。然后在node中运行代码。
$ npm install request
安装请求。
var request = require('request')
要求安装的库。
您还需要修改代码并提供适当的回调函数。您可以阅读请求文档here .
关于javascript - Kik 机器人 | Uncaught ReferenceError : require is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40411115/