0
我尝试使用全局函数,我可以使用一些mysql函数,但问题是,js说“.then”是未定义的,是什么让我错了,这只是一个语法错误?Node.js无法读取未定义的属性'then'
static connectWidthCortex(){
xdevapi.getSession({
host: 'localhost',
port: 33060,
dbUser: 'admin',
dbPassword: 'xxxx'
}).then((session)=> {
return session.getSchema("cortex");
});
};
static createCollection(collname){
this.connectWidthCortex().then((db)=> {
console.log("Cortex connected")
return db.createCollection(collname);
}).catch((err)=> {
console.log("connection failed")
});
}
THX的帮助:)
我猜'connectWidthCortex()'的返回值不是承诺。你可以检查一下吗? – GPX