I'm currently developing some code using node.js. I'm looking to save the state of something in the attributes of the "this" item or "session" within the index.js. Here's how the code looks:
function getAlexaState(){ if(typeof this.attributes == 'undefined'){ // Completely new instance this.attributes = { AlexaState : '' }; this.attributes.AlexaState = <somestring>; return this.attributes.AlexaState; } else{ return this.attributes.AlexaState; } };
Whenever I call to "this" or use "this.session" it tells me that it is undefined (specifically "this" is undefined, not it's properties), as I'm trying to follow the example code's use of this here (https://github.com/alexa/skill-sample-nodejs-highlowgame/blob/master/src/index.js). I'm tempted to just save these values to DynamoDb and retrieve it constantly whenever I have an intent triggered. This happened both locally and on my Lambda instance (Using the "Alexa Start Session" as the testing config).
What could be the issue?