so what I want to do is to create a session and store it in redis. I followed the API from this github repository https://github.com/tj/connect-redis.
But I am getting this error in the word client: The expected type comes from property 'client' which is declared here on type 'RedisStoreOptions'.
This is the code that i used:
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 occurs here:
store: new RedisStore({ client: redisClient })
More specifically in the word client.
instead of
import redis from 'redis';
use
import * as redis from 'redis';
I'm guessing your using TypeScript, I had this issue, did you install:
@types/redis
@types/connect-redis
@types/express-session
I did that and kept getting an error with the client so I uninstalled all 3 @types and noticed redis doesn't require you to declare modules so I only installed types for express-session and connect-redis
npm i @types/connect-redis @types/express-session --save-dev
yarn add @types/connect-redis @types/express-session -D