I am doing a post on server and trying to console output the response http code. I used chrome tool as debugger to check response and I can see the output coming but at the end it goes to subscribe library does something and sets the function rather than value.
My component class is
export class MicroserviceCreateComponent implements OnInit{
errorMessage: string;
postMessage: string;
teams: Team[];
microservice: Microservice[];
constructor(private microserviceService: MicroserviceService) { }
ngOnInit() {
}
onSubmit({ value, valid }: { value: Microservice, valid: boolean }) {
this.createMicroservice(value);
console.log(this.postMessage); <<<<<<<<==== This gives me undefined
}
createMicroservice(value){
this.microserviceService.createMicroservice(value).subscribe(
postMessage => this.postMessage = postMessage.valueOf(),
error => {
this.errorMessage = error.getMessage();
console.error(error.getDescription());
});
}
}