I'm trying to set a class member variable from a callback of a function I'm calling from the class constructor.
To be a bit more specific: I need to set the connection ID in the Connection class constructor based on the Redis INCR result (each client has a 'global' connection ID so I can have multiple nodes).
Here's the code.
class Connection {
  constructor() {
    client.incr('conn_id', (err, reply) => {
      this.connID = reply;
    });
  }
}
var lovely = new Connection();
console.log(`lovely connID is ${ lovely.connID }`);
This is the result: lovely connID is undefined
 
    