I currently am managing code that has this function
public getData(somei: Somei): Promise<SomeD> {
return new Promise((resolve, reject) => {
this.getSomeD(somei).subscribe((someData: SomeD) => {
resolve(someData);
});
});
}
This works fine. I would like to add a then to perform an action after the code above executes but I dont seem to get it to work. I tried it like
public getData(somei: Somei): Promise<SomeD> {
return new Promise((resolve, reject) => {
this.getSomeD(somei).subscribe((someData: SomeD) => {
resolve(someData);
});
}).then(()=>{callanotherFunction()});
}
but I get the typescript error
Type 'Promise<void>' is not assignable to type 'Promise<SomeD>'.
I imagine I have to return the right object type? I should say I am not that familiar with promises.