I am able to gather data just fine from DynamoDB, but I am getting a TypeError undefined when I try to pass the data to a controller with an AngularJS service.
// Query for Replicated Site Using Name
coachdb.query(param, function(err,data) {
if (err) {
console.log(err, err.stack); // an error occurred
} else {
if (data.Items.length > 0) {
//console.log(data); // THIS IS LOGGING DATA
var x = (data);
var y = x.Items[0];
console.log(x.Items[0]); // THIS LOGS DATA
console.log(y); // THIS LOGS THE SAME DATA
this.coach = function() {
return y; // THIS SEEMS TO BE WHERE MY ERROR IS COMMING FROM.
}
if ("firstName" in x.Items[0]) {
var firstName = x.Items[0].firstName.S;
alert(firstName); // THIS PRODUCES AN ALERT THAT WORKS
}
}
}
});
I can also manually create an Object, which is functially equivalent to what i'm pulling from DynamoDB and I that works just fine.
var nestObject = {
"company": { "S" : "ACME"},
"email" : {"S" : "[email protected]"},
"firstName" : {"S" : "Jared"},
"lastName" : {"S" : "Whipple"},
"phone" : {"S" : "435.494.3333"},
"repNum" : {"N" : 12164}
};
this.coach = function() {
return nestObject;
}
How can I get data from DynamoDB to pass Table Name: ximoRepList