mubeen mubeen - 1 year ago 203
Node.js Question

Promisify Redis client

How can I

promisify redis
so that I could use

I have tried to promisify client:

var redis = require('redis');
var client = redis.createClient();

client.on('connect', function(){
console.log('Redis connection is up');


But it responds with error:

client.lrange(...).then is not a function

PS: The callback code works fine, so it means server is running perfectly.

Answer Source

When using promisifyAll, the promisified methods get an -Async suffix:


As per the documentation:

Note that the original methods on the object are not overwritten but new methods are created with the Async-suffix. For example, if you promisifyAll the node.js fs object use fs.statAsync to call the promisified stat method.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download