Recently, I've been working on a project where I needed to create and store a session in redis. To achieve this, I referred to the API documentation provided by this GitHub repository https://github.com/tj/connect-redis.
However, I encountered an issue related to the word client while implementing the code. The error message stated: "The expected type comes from property 'client' which is declared here on type 'RedisStoreOptions'."
Here is the snippet of the code that led to the error:
import redis from 'redis';
import session from 'express-session';
import connectRedis from 'connect-redis';
const app = express();
const RedisStore = connectRedis(session);
const redisClient = redis.createClient({ legacyMode: true });
redisClient.connect().catch(console.error);
app.use(
session({
store: new RedisStore({ client: redisClient }),
saveUninitialized: false,
secret: "keyboard cat",
resave: false,
})
)
The error seems to be directly related to the following line of code:
store: new RedisStore({ client: redisClient })
Specifically, it points out an issue with the word client within the code block.