DEV Community

Discussion on: Host and Use Redis for Free

Collapse
 
amreshsinha profile image
Amresh Prasad Sinha • Edited

Is it now not working? I tried the exact same thing but it prints out nothing on the console.
Here's the code:

const redis = require("redis");
require("dotenv").config();

const client = redis.createClient({
  host: process.env.REDIS_URI,
  port: process.env.REDIS_PORT,
  password: process.env.REDIS_PASSWORD
});

client.on("connect", () => {
  console.log("Connected to our redis instance!");
  client.set("Greatest Basketball Player", "Lebron James");
});
Enter fullscreen mode Exit fullscreen mode

One more thing... This thing works fine in npm package redis@3.1.2 but not with latest 4.0.3 (as of now)

Any help will be appreciated.
Thanks!

Collapse
 
ramko9999 profile image
Ramki Pitchala

I see, so if I understand it correctly. There wasn't an error with redis@3.1.2 but it didn't print "Connected to our redis instance!" to the console. But with 4.0.3, it gave an error when compiling?