Below is my service method:
public saveCustomFieldsData(customAttributes) {
// return this.httpc.post(url, customAttributes, {headers: httpOptions.headers})
// .pipe(map(res => res)); //Working
customAttributes.forEach(function (arrayItem) {
if(arrayItem.action == 'edit') {
return this.httpc.post(url, customAttributes, {headers: httpOptions.headers})
.pipe(map(res => res)); //Not working
}
});
}
I am calling this from my component
this.customFieldsService.saveCustomFieldsData(this.customAttributes).subscribe((res: any[]) => {
// logic
});
This is working with commented code which does not have the if
condition. But when I try to move this HTTP call inside forEach
and if
condition, I am getting Property 'subscribe' does not exist on type 'void'
error. How do I modify my code to work from inside forEach
and if
condition?