Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

es6 call class methods from within same class

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.

like image 396
Andrew Mata Avatar asked Mar 04 '16 00:03

Andrew Mata


1 Answers

Use this

import blah from './blaha';

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

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

  meth2(paramB) {
     this.meth1()
  }
}
like image 161
dcohenb Avatar answered Oct 16 '22 20:10

dcohenb