错误类型错误:无法读取未定义的属性“get”

has*_*van 6 typescript angular

在此处输入图片说明错误类型错误:无法读取未定义的属性“get”

我是 Angular 新手,我真的需要帮助,并提前致谢

constructor(private http: Http, private authService: AuthService, private router: Router) {
	this.token = localStorage.getItem('token');
	
	if(token){
		this.interval = setInterval(this.ingameee, 5000);
	}
}

ingameee() {
   this.http.get('http://url.com/api/matchmaking/keepalive?token='+ this.token)
          .subscribe(
              response => {
                  this.dataa = response;
                  this.mod = this.dataa.json().mod;
                  this.playersinqueue = this.dataa.json().playersinqueue;
                  this.region_id = this.dataa.json().region_id;
                  this.party_id = this.dataa.json().party_id;
                  },
              error => console.log(error),
          );

  }
Run Code Online (Sandbox Code Playgroud)

Pen*_*gyy 6

请记住arrow function用于在使用回调时保持上下文,因为this(上下文)会改变。

this.interval = setInterval(() => this.ingameee(), 5000);
Run Code Online (Sandbox Code Playgroud)