I am trying to make multiple API request to an endpoint in which the values are iterated over an array
So I used rxjs forkJoin to achieve this
//array to keep obeserbles
propOb: Observable<any>[];
input.property.forEach(property => {
console.log('prop', property);
const t = this.baseApiService.sendRequest(
'json',
{
method: 'post',
endPoint: 'v1/property/new',
data: {
property_id: uuid.v4(),
ics_ref_no: '122',
property_type: property.type,
property_role: property.role,
property_dec: property.description,
}
});
this.propOb.push(t);
});
forkJoin(this.propOb).subscribe((data) => {
console.log(data);
});
While running i am getting the following error cannot read property 'push' of undefined from this line this.propOb.push(t);
Also, I'm not sure my approach is correct or not