Error while calling API using angular CLI


#1

auth.services.ts file ( Function for call API )

public web_url = ‘URL PATH’;

-> register(user) {
//debugger;
alert(this.web_url);
var reply = this.http.post((this.web_url+“register”),user).map((response: Response) => {
//debugger;
response.json() }
);
return reply;
}

signup.component.ts

-> public onRegister() {
alert(JSON.stringify(this.user));
console.log(this.user);
//debugger;
var response = this.authService.register(this.user).subscribe(
data => {
var results = data;
//debugger;
console.log(results);
}
);
this.router.navigate(["/login"]);
}

=>> Got undefined in response , any suggestion please ??


#2

Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

Also: How is this connected to angular CLI?