I am working with Typescript in Ionic 4. My problem is, that the part of the inner function is processed after the outer part, though the outer part of code is written under the inner part. That is a big problem for me, because the return value is always wrong. If I want the right value, I have to call the function twice. Here is my code, which you can also see in the linked picture here. The function only reads a json file and returns the json object.
ReadFile(filename: string, fileFunktion: string) {
this.http.get(filename).subscribe((data) => {
this.data = data;
});
return this.data;
}
Can you give me advice, how to fix this problem? Thank you :)