I am learning node.js
I have a class like this ->
const client = require('prom-client');
class PrometheusController {
constructor () {
let counter = new client.Counter({ name: 'http_total_requests', namespace:"test", help: 'test' });
}
get (fn) {
this.counter.inc(); // Inc with 1
}
Node js complains that the counter is undefined.
I tried saving the this
variable as the posts here recommend but that is not accessible either - javascript class variable scope in callback function
How do I access the constructors variables?