I need to use httpclient into foreach loop. It is possible? What is the right way? Here is my code:
this.attachToDelete.forEach(
element => {
this.documentService.DeleteAttachment(element, this.newDocumentId.toString());
console.log("upload delete from submit", element);
}
);
and this is the method in correspondig service:
public DeleteAttachment(attachmentId: number, documentId: string) {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json; charset=utf-8');
return this.http.post('http://localhost:8080/DocumentAPI/api/document/RemoveAttachment?docId=' + documentId + '&attachmentId='+attachmentId, attachmentId, { headers: headers }).subscribe(
data => {
if(data)
console.log("delete attach????", data);
else{
console.log('Error occured');
}
}
);
}