Store variable into memory

Hello,

I am trying to store message entered by user into a variable

let date = app.prediction.entities.date[0].value.value;
let d1 = new Date(date);
let d2 = new Date();

if (d1.getTime() - d2.getTime() > 0){
app.memory.set(‘date’, date);
app.log(app.memory, ‘memory’)
app.log(“Inside future date”);
return resolve();
}

however date is not stored in memory
log message :

6 minutes ago printing context message {}
6 minutes ago firsttimeusernotyellowmessenger -x1594876894265- 579129941863219706172663239
6 minutes ago printing context message {}
6 minutes ago {}
6 minutes ago firsttimeusernotyellowmessenger -x1594876894265- 579129941863219706172663239
6 minutes ago printing context message {}
6 minutes ago error
6 minutes ago Inside date validator
6 minutes ago memory {}
6 minutes ago Inside future date
6 minutes ago error
6 minutes ago {}

here you can see that memory is empty, despite execution enters the loop.

How can I solve this ?

Hi Ganesh,

For getting the value from memory you can use the following syntax

app.memory.get(“date”)
.then(date=>{
app.log(date,“DATE FROM MEMORY”);
}).catch(err=>{
app.log(err, “ERROR WHILE FETCHING DATE FROM MEMORY”)
});

For more information on app.memory you can check here https://yellowmessenger.atlassian.net/wiki/spaces/docs/pages/535298077/app.memory