I'm working on a Alexa Skill lambda and have created small code fragment to illustrate my problem:
exports.handler = function(event, context)
{
//CREATE A MODEL
var model1 = {"endpoints":[ ]};
//CREATE ANOTHER MODEL
var model2 = {"endpointid": "stuff"};
//CREATE THE RESULT
var result = model1;
model2.endpointid="switch1";
result.endpoints.push(model2);
model2.endpointid="switch2";
result.endpoints.push(model2);
var json = JSON.stringify(result);
context.succeed({json});
};
Response:
{
"json": "{\"endpoints\":[{\"endpointid\":\"switch2\"},{\"endpointid\":\"switch2\"}]}"
}
Question: Why do I get two of the same endpointid
s?