-1

Here we will tell you the solution for call HTTP client POST request in angular 8

1 Answers1

0

Below are the answer for the call formDatas email and password in send request

var formDatas = "email=" + this.loginForm.get('email').value + "&password=" + this.loginForm.get('password').value;

  this.authService.authLogin(formDatas).subscribe(
    data => {
      if (data['ResponseCode'] == 1) {
        localStorage.setItem('data', JSON.stringify(data));
        JSON.parse(localStorage.getItem('data'));
        alert("login success");
        this.router.navigate(['/map']);
      }
      else {
        alert("error");
      }
    },
    error => {
      let t = error
      alert(t['error']['Comments']);
    }
  )
  • pass the formDatas and stringify with it to JSON.stringify function and uses header application/x-www-form-urlencoded* LIKE THIS request = request.clone({ headers: request.headers.set('Content-Type', 'application/x-www-form-urlencoded') }); Above example works for me in angular 8 when I am using header *application/x-www-form-urlencoded* – Arvind verma Jan 09 '20 at 10:17