I'm getting the response from my API like-
0:
action: "Add"
date: "2021-09-22T00:00:00"
level: 1
module: "[Mode001]"
oldRecord: "{\"Code\": 7,\"Name\": \"F0002\",\"Type\": \"Feat}"
newRecord: "{\"Code\": 7,\"Name\": \"F0001\",\"Type\": \"Feature}"
remark: null
Here, all the field values are received as string. I want to show the oldRecord & newRecord fields in separate table.
Component code-
this.searchPendings = this.service.get(obj).subscribe(res => {
this.dataSource = res.apiData;
console.log(res.apiData);
// I want to extract the oldRecord & newRecord from the res.apiData to work further
var anyt = JSON.parse(res.apiData) // throws error in console
})
How can I convert the two specific field values from string to Json & show it in a table like-
newRecord | oldRecord |
---|---|
Name: F0002 | Name: F0001 |