Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
51
rated 0 times [  55] [ 4]  / answers: 1 / hits: 39101  / 8 Years ago, fri, march 4, 2016, 12:00:00

I'm trying to call a class method in my class form a neighboring method as shown in the example below.



import blah from './blaha';

export default class myclass{
constructor(con) {
this.config = con;
}

async meth1(paramA) {
//do_stuff...
}

meth2(paramB) {
//attempt to call meth1()
}

}


I would like to call a method from within a different method using es6 class styles.


More From » node.js

 Answers
35

Use this



import blah from './blaha';

export default class myclass{
constructor(con) {
this.config = con;
}

async meth1(paramA) {
//do_stuff...
}

meth2(paramB) {
this.meth1()
}
}

[#63055] Wednesday, March 2, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zariahdiamondz

Total Points: 649
Total Questions: 109
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;