I am getting data back from a web-server and I am trying to access the data within the JSON object. I am having some issues with accessing it.
The JSON looks like this:
{
"faults": [
{
"FaultCodeType": "X",
"ErrorType": "System",
"Description": "Response failed for reason 1"
},
{
"FaultCodeType": "Y",
"ErrorType": "System",
"Description": "Response failed for reason 2"
}
],
"responseInfo": {},
"responseInfo2": {},
"responseInfo3": {}
}
Should I use JSON.parse?
JSON.stringify?
I have the method:
loadData(dataPassed) {
this.angularService.searchWithData(dataPassed).subscribe(
data => {
const fault = data[0];
const fault2 = data[1];
console.log('Data is here = ' + data); // returns the JSON
console.log('Request = ' + JSON.stringify(data)); // shows the JSON
console.log(fault); // undefined
console.log(fault2); // undefined
}
}
It is not working though, any help would be greatly appreciated.