我目前正处于使用 Node.js 编写小型 Circuit Bot 的第一步。
这是我到目前为止得到的:
const Circuit = require('../node_modules/circuit-sdk/circuit.js'); //Circuit-Library importieren
var config = require('./config.json'); //Configs für Bot
console.log(config); // Configs ausgeben
var client = null;
client = new Circuit.Client({
client_id: config.client_id,
client_secret: config.client_secret
});
client.logon()
.then(user => console.log('Logged on'))
但是由于抛出 TypeError,客户端无法登录:
TypeError: XMLHttpRequest is not a constructor
at /home/jovyan/node_modules/circuit-sdk/circuit.js:59768:37
at new Promise (<anonymous>)
at xhr (/home/jovyan/node_modules/circuit-sdk/circuit.js:59767:20)
at /home/jovyan/node_modules/circuit-sdk/circuit.js:60283:17
at new Promise (<anonymous>)
at authenticateClientCredentials (/home/jovyan/node_modules/circuit-sdk/circuit.js:60282:20)
at Object.circuit.Client._self.logon (/home/jovyan/node_modules/circuit-sdk/circuit.js:63899:24)
at evalmachine.<anonymous>:5:8
at Script.runInThisContext (vm.js:116:20)
at Object.runInThisContext (vm.js:306:38)
我尝试了与身份验证参数的所有可能组合,例如使用对象声明它们或尝试使用登录功能推送它们。