I'm assuming I have an issue with my JSON data, but I can't seem to debug.
A snippet of data I get back from a service looks like:
{
"result" :{
"version" : "0.1",
},
"recordData":{
"carId": {
"config": "auto",
"val": "none"
},
"carName": {
"config": "manual",
"val": "bmw"
}
}
My Angular code looks like:
var modifyModel = function(data){
return {
carId: data.carId.val,
carName: data.carName.val
};
};
if (data.recordData){
modeldata.results = data.recordData.map(modifyModel);
}
return modeldata;
I have the same code working on another JSON request, however the data comes across as an array, and the error I get back from the above is:
TypeError: data.recordData.map is not a function
So I guess I need to clean up the data I receive somehow?
mapfunction is for an array[]rather than an object{}. Try usingtypeof data.recordDatain your debugging.