I have a service that returns a map of key values pairs Map<String, List<String>>
{
"code1": [
"F10",
"F11"
],
"code2": [
"F12",
"F13"
]
}
I am trying to hold this response in angular app
getCodes(): Observable<Map<string, string[]>> {
return this.http.get<Map<string, string[]>>(url, {headers})
.pipe(map((response: Map<string, string[]>) => {
return response;
}));
}
and after I subcribe to the observable and try to access the map with key, I am getting an error this.codes.get is not a function
Component:
codes = new Map<string, string[]>();
this.service.getCodes().subscribe(response => {
this.codes = response;
console.log('for code1', this.codes.get('code1'));
}
when I log the response, it is not looking like a map. Pls help