private Payload(): asset {
const payload = { //pay load }
return payload;
}
public listofnumbers() {
number = [1,2,3];
number.forEach(element => {
this.service(element);
});
}
private service(number) {
this.service.getNumbers(this.Payload())
.subscribe((res) => {
if (res.isSuccess && res.data) {
this.function();
}
})
}
function () { alert("fghj"); }
When the service is called, instead of executing the HTTP call first, it calls a method inside the service. Feeling confused about what to do next?
Consider using forkjoin
public sendSelectedToD365() {
let assetDetails1 = [];
let assetSearchValue =(this.searchAssetForm.controls['assetSearch'].value).split(',');
let mycalls = assetSearchValue.map(x => this.trying(x))
forkJoin(mycalls).subscribe(res => {
console.log(res)
})
}
private trying(x)
{ this.assetService.getAssetDetails(this.AssetDetailsPayload(x)).subscribe((res) => {
if (res.isSuccess && res.data) {
return res.data;
}
})
}
Not happy with the current implementation? Try using forkjoin, but it's not working as expected.