After executing a promise, I am looking to access the data that is returned as a JSON hashmap. Each key and its corresponding value needs to be displayed in separate dialog boxes:
I have attempted to access the data using the following method:
component.ts :
openDialog(emaildialog){
this.emailservice.getByEmailType(this.choice).then((emails: any) => {
this.etext = emails.responsive;
console.log(emails.responsive);
let ref = this.dialog.open(emaildialog, {
data: emails.responsive,
width: "600px",
height: "600px",
});
});
}
service.ts:
constructor(private http: HttpClient) { }
getByEmailType(id:String) {
return this.http.get<Email>(this.baseUrl+'/'+id).toPromise();
}
The API in Springboot backend returns the following data:
return new ResponseEntity<Object>(Collections.singletonMap("responsive",hmap), HttpStatus.OK);
The returned JSON appears as follows:
{
"responsive": {
"email3": "hello to email3",
"email2": "hello to email2",
"email1": "hello to email1",
"email5": "hello to email5",
"email4": "hello to email4"
}
}
To display each email type with its corresponding value, I need to showcase them in individual dialog boxes.