Cannot read property of undefined in json using backbone
I have a json file like this:
"_id": {
"$oid": "51f8efd2d939b0e450b8d3d8"
},
"timestamp": {
"$date": "2013-09-03T11:53:22Z"
},
"name": {
"$ref": "vcc_user",
"$id": "4f0bc7c71397f53febaca73e"
},
and in backbone collection I have this, and i want to fetch data from url.
defaults : {
id : null,
name : null,
timestamp : null
},
parse : function(response){
response.id = response._id.$oid;
response.created = response.created.$date;
response.timestamp = response.timestamp.$date;
response.name = response.name.$ref;
return response;
},
it recognize everything except ref and it ways this error.
Uncaught TypeError: Cannot read property '$ref' of undefined. Why is it
like that?
No comments:
Post a Comment