const schema = {
date: new IsRequiredValidator(),
time: new IsRequiredValidator(),
duration: new IsRequiredValidator()
};
const validation = this.validate(schema);
//Time
if (this.$session.$data.time == undefined)
{
if (validation.failed(‘time’))
{
return this.ask(“Please tell me when you want to reserve the room?”);
}
else
{
console.log(’\n’ +’\n’ +’\n’ + ‘Made It Before’ +’\n’ +’\n’ +’\n’);
this.$session.$data.time = this.$input.time.value;
console.log(’\n’ +’\n’ +’\n’ + ‘Made It After’ +’\n’ +’\n’ +’\n’);
}
}
When input is given, I save it to a session variable. The user is then re-prompted. The same intent is triggered, but the input the user has already given remains as it is part of the session. Eventually, the user has given all the input I need and, it has all been stored in session variables… Or at least, that is supposed to be how it works.
Instead, on this line:
this.$session.$data.time = this.$input.time.value;
I get a “Cannot read property ‘time’ of undefined” error message. This makes sense because the session variable ‘time’ is undefined. However, i do not know how to define ‘time’. I apologize if this is a dumb question, I am still figuring out JS.
Thanks in advance.