I am using angular to fetch data from API which has some values as null, I want to change this values to an empty string.
sample JSON from API
[
{
"id": 84,
"employee_name": "Alan",
"phone_number": "",
"process": null,
"joining_date": null
},
{
"id": 85,
"employee_name": "Bob",
"phone_number": "",
"process": {
"id": 1,
"process_name": "Moulding"
},
"joining_date": null
},
]
I have successfully changed these null values to an empty string while displaying them in a material table. But that means repeating the same code many times, so I want to do this transformation at a higher level i.e. on an HTTP get request.
api get request
public getAll(): Observable<any[]> {
return this.http.get<any[]>(`${this.apiURL}/${this.specificURL}/`);
}
I think it can be done using rxjs 'map' operator but I really don't know how to do it.
pipe(map(res =>.....));