I can get rest webservice response and console it in screen without any problem. But unfortunately, in the page I can see initial value of the result of the werbservice call. What I need to do render the page after I get response from wbservice? I meant I can see userInfo and userName's initial values. You can see the snippet below.
Regards Alper
export class NavigationComponent implements OnInit {
response:any;
errorMessage:any;
form:FormGroup;
obj = {"one": "", "two": "", "three": "", "four": ""};
webserviceUrl = "https://httpbin.org/post";
webServiceUrlGet = "https://jsonplaceholder.typicode.com/posts/1";
username = "alper"
userInfo = "alper Info";
componentName = 'AppComponent';
ngOnInit():void {
this.getUserName();
}
getUserName() {
this.http.get(this.webServiceUrlGet)
.subscribe(
function (data) {
this.userInfo = data.json();
this.username = this.userInfo.userId;
},
error => this.errorMessage = <any>error);
return this.username;
}