I'm facing an issue with the observables in my service setup. Here is how it looks:
return Observable.forkJoin(
this.http.post(this.baseUrl, JSON.stringify(user), this.serverConfig.getJsonHeader()),
this.awsService.uploadData(params)
)
In my component, I subscribe to them like this:
.subscribe(
data => {
console.log('data[0]',data[0]);
console.log('data[1]',data[1]);
}
);
There's also a uploadData
function I have implemented:
uploadData(params: any): Observable<any> {
return Observable.of(
this.getBucket().upload(params,
(error, resp) => {
console.log('error', error);
console.log('resp', resp);
}
)
)
}
The issue I'm facing is that the callback function within the uploadData method is running after the subscription instead of before. How can I make sure the callbacks run before the subscription? Any suggestions on what I should do?