I have a function which is as follow.
public getAssemblyTree(id: number) {
....
const request = from(fetch(targetUrl.toString(), { headers: { 'responseType': 'json' }, method: 'GET' }));
request.subscribe(
(response) => {
response.json().then(data => {
assemblyNodesForTree.push(...this.parseAssemblyTree(data['flat_assembly_graph']));
}
)
}
)
console.log(assemblyNodesForTree)
return assemblyNodesForTree;
}
I realised that the function is returning assemblyNodesForTree without the observable completing. I was wondering what may be the right way to go about this?