0

Inside my Component ts file , I' ve a "connexion" method:

export class MyClass {
  isOpen = false

  openConnection(url) {

    this.socketClient.connect(this.tokenheader, (response) => {
        this.isOpen = true;
        this.getResponse()
      },
      this.errorCallBack
    );
  }

  errorCallBack(error) {
    this.isOpen = false; // CANNOT READ 'isopen' of undefined
    console.log("Connexion failure" + error);
  }
}

This method returns several callbacks for "response" and "error".

As you can see i ve the call of "this.errorCallBack" when error

it's used to print the error message ;

but i ve to set my class variable to false (this.isOpen = false;)

but i get :

CANNOT READ 'isopen' of undefined

Sugesstions ??

Ele
  • 31,191
  • 6
  • 31
  • 67
firasKoubaa
  • 4,824
  • 15
  • 46
  • 104

0 Answers0