【发布时间】:2017-02-28 09:09:57
【问题描述】:
我尝试使用一个全局函数,我可以在其中使用一些mysql函数,但问题是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")
});
}
感谢帮助:)
【问题讨论】:
-
我猜
connectWidthCortex()的返回值不是一个承诺。可以查一下吗?
标签: javascript mysql node.js