I have saved an object in Redis in this format
let redisObject = {
sessionID: this.data.sessionID,
forWardTime: new Date(),
};
I am calling the object and the data is being retrieved successfully
let redisData = await this.getDataFromRedis ....
And the weird part I am being able to log the Redis data example
console.log("redisData =>",redisData)
it is returing
redisData => {"sessionID":"OyMUuUgeimTeU3OfNWyDtgkGeHsniF","forWardTime":"2022-03-22T19:16:05.507Z"}
But
console.log(redisData.sessionID)
And
console.log(redisData.forWardTime)
are both returning undefined? What's the problem and what am I missing
Your getDataFromRedis() function isn't parsing the data, so you're logging the JSON string, not an object.
Change to:
let redisData = JSON.parse(await this.getDataFromRedis(...));