I have a json file that contains multiple arrays structured like this:
{
A[]
B[]
C[]
...
}
This is the query I am using:
myFunction():void{
this.apiService.getData()
.pipe(
map((response: any) => response.A), // to access to the 'A' array
take(1)
)
.subscribe((records: MyType[]) => {
this.records = records
});
}
The above query needs to be repeated for each array, with only the name of the array changing (e.g., from 'A' to 'B', 'C').
I am looking for a way to pass a variable to the function and implement a 'switch case' to handle redirection to the correct table.
I considered using the switchMap operator but it does not seem suitable in this scenario.
Any suggestions would be greatly appreciated!
Thank you