I have a function that looks like this:
public getAssemblyTree(id: number) {
....
const request = from(fetch(targetUrl.toString(), { headers: { 'responseType': 'json' }, method: 'GET' }));
request.subscribe(
(response) => {
response.json().then(data => {
(this.parseAssemblyTree(data['flat_assembly_graph']));
}
)
}
)
public updateAssemblyTree(id: number) {
let res = this.getAssemblyTree(id)
this.asmTree.next(res);
}
I need the data returned once the observable completes by the first function to be stored in the variable "res" in the second function (public updateAssemblyTree(id: number)). Can someone provide guidance on how to achieve this? I am new to using observables, so having the code written out would greatly assist me. Thank you all for your help in advance :)