Reputation: 61
I'm using redis-om with nodejs and I'm facing error !!
RedisError: Redis connection needs to be open
When I try to divide the app logic into controllers, routersit gets crashed , But it works completely fine if I make all the api's and endpoint in the main file (server.js) !!
The controller file's code :
Upvotes: 0
Views: 562
Reputation: 2369
Your controller code has no opening of the redis client , you are only create a new client and then call it before opening it ,error is coming from the line
redisClient.fetchRepository(codeSchema)
here you are trying to use redis client before opening it
Have the file connecting redis client right after line 4
Below will work
const redisClient = new Client()
await redisClient.open('redis://localhost:6379')
then call
redisClient.fetchRepository(codeSchema)
Upvotes: 1