Following is my model.
export interface AuditTrail {
logAction:string,
targetEmpId:string,
createdDate:Date
}
Code below retrieves data from a GET call and transforms it.
public getAuditTrails() {
return this.http.get<AuditTrail[]>(this.auditTrailUrl)
.pipe(
map((data :Object[]) => {
return data.map(value => {
const auditTrail:AuditTrail = {
logAction:value["logAction"],
targetEmpId:value["targetEmpId"]["empCode"],
createdDate:value["loggedDateTime"]
}
return auditTrail;
});
})
)
}
This code works alright. However my question is how can I avoid the array
iteration data.map(value => {and use rxjs operators for the same.
The question is intended to improve my understanding of rxjs operators hence the solution should use rxjs operators.