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
  • 32,412
  • 7
  • 33
  • 72
firasKoubaa
  • 5,599
  • 17
  • 66
  • 133

0 Answers0