I have two functions that return an Observable
:
//get a new entity from server
public new(): Observable<any> {
return this.http.get<any>(api + 'New');
}
//create the entity
public create(data: any) {
return this.http.post(api + 'Update', data);
}
Now, I need to write a function that calls these two functions and returns an Observable
:
addNewItem(value: any): Observable<any> {
this.service.new().subscribe(x => {
// do something with "X"
return this.service.create(x);
});
}
But, this does not work because return
is inside subscribe
.