Why I have to use a Semi-colon before my code?

岁酱吖の 提交于 2019-12-11 19:15:33

问题


I have this code:

this.userService.register(value).pipe(
    finalize(() => this.isRequesting = false)
).subscribe(
    () => this.router.navigate(['/login'], { queryParams: { brandNew: true, email: value.email } }),
    (error: any) => this.errors = error
);

It doesn't work until I put a semicolon before this.router:

() => ; this.router.navigate(['/login'], { queryParams: { brandNew: true, email: value.email } }),

It is really weird, why should this be happening? It has nothing to do with this.router.navigate because if I replace it by an alert like this alert('alert') it doesn't work again until I put a semi-colon before it. It seems really odd to me, would you please help me with this?

Also the error that it throws is just a simple [object Object] which makes me more confused, I have also looked at this question but changing the browser to chrome had no effect: Resolver Emitting Error ` ERROR Error: "[object Object]" `

This is the register method of the userservice:

register(userRegistration: UserRegistration): Observable<{}> {

  let headers = new HttpHeaders({ 'Content-Type': 'application/json' });

  return this.http.post(this.baseUrl + "/account", userRegistration, { headers: headers });
}

来源:https://stackoverflow.com/questions/55627197/why-i-have-to-use-a-semi-colon-before-my-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!