본문 바로가기
MySql

MySQL Node.js는 정의되지 않은 'then'속성을 읽을 수 없습니다.

by 베이스 공부 2020. 10. 28.
반응형

일부 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")
});
}

도움을위한 Thx :)

 

해결 방법

 

connectWidthCortex 의 반환 값에 대해 then 을 호출하려고합니다.

connectWidthCortex 함수는 return 이 없으므로 undefined 를 반환합니다.

getSession 호출이 제공하는 promise를 반환하려면 return 문이 필요합니다.

return xdevapi.getSession ({…

 

참조 페이지 https://stackoverflow.com/questions/42504447

 

 

반응형

댓글