I have these 2 backend call methods. When I try to debug these, after getting a response from isExisting method
updateDocumentHttp method is calling, but the response is not getting, the control just goes away. Is there any wrong I'm going, or is there any better solution for this?
this.dataService.processUpdateDocument(isExistingUrl, isExistingCriteria).subscribe();
@Injectable()
export class DataService {
processUpdateDocument(httpMethod, baseUrl, doc):Observable<any> {
if (httpMethod == 'POST') {
return this.isExisting(isExistingUrl, isExistingCriteria);
} else {
return this.updateDocumentHttp(httpMethod, baseUrl, doc);
}
}
isExisting(isExistingUrl, isExistingCriteria): Observable<any>{
return this.http.post(isExistingUrl, isExistingCriteria)
.pipe(map((response:[]) =>{
console.log("Already exist Result: " + response.length);
if (response.length <= 0) {
return this.updateDocumentHttp(httpMethod, baseUrl, doc, options, domainToUpdate, callback, messages)
}
}
updateDocumentHttp(httpMethod, baseUrl, doc):Observable<any> {
return this.http.request<IApiResponse>(httpMethod, baseUrl, {
body: doc,
responseType: "json"
}).pipe(map(
data => {
console.log("Created / Updated : Successfully");
if (!domainToUpdate) {
app.childScope["domain"] = data;
}
return true;
}
)
});
}
}