TypeError: Converting circular structure to JSON when trying to POST request

前端 未结 6 1014
星月不相逢
星月不相逢 2021-02-12 15:34

I am getting the error in the title and here is the full stack trace, i am not sure what it is, any insight is welcomed!

browser_adapter.js:84 EXCEPTION: Error i         


        
6条回答
  •  [愿得一人]
    2021-02-12 16:14

    use form.value as the following code:

          onSubmit(form: NgForm) {
            this.userService.login(form.value).subscribe(
              (res: any) => {
                localStorage.setItem('token', res.token);
                this.router.navigateByUrl('/home');
              },
              error => {
                if (error.status == 400)
                  this.tostarService.error('Invalid Username or password!', 'Authentication Failed');
                else
                  console.log(error);
    
              }
            );
          }
    

提交回复
热议问题