I have some problem returning a string from my request.
getTest(id: string): string {
let foo: string = '';
this.service.testProfile(id).subscribe(
response => {
foo = response.body.foo;
},
error => {
console.log(error);
}
)
return foo;
}
I want to init foo to my response. foo and then just to return new value of foo. Everything work but there is no result, any idea what I'm doing wrong?
Thank
foo= response.body.foo;is executed AFTER the return statement. That's why is always an empty string