use node-redis with node 8 util.promisify
If you are using node v8 or higher, you can promisify node_redis with util.promisify as in:
const {promisify} = require('util'); const getAsync = promisify(client.get).bind(client); // now getAsync is a promisified version of client.get: // We expect a value 'foo': 'bar' to be present // So instead of writing client.get('foo', cb); you have to write: return getAsync('foo').then(function(res) { console.log(res); // => 'bar' });
or using async await:
async myFunc() { const res = await getAsync('foo'); console.log(res); }
culled shamelessly from redis official repo
changing let get = util.promisify(client.get);
to let get = util.promisify(client.get).bind(client);
solved it for me :)