add exception for when there are no keys
This commit is contained in:
parent
ff2907cadd
commit
1d115164f0
|
@ -22,6 +22,7 @@ class Counter {
|
|||
|
||||
async list () {
|
||||
let keys = await this.redis.keys('*')
|
||||
if (keys.length == 0) { return {} }
|
||||
let vals = await this.redis.mget(keys)
|
||||
/* combine list of keys and values into an object */
|
||||
return keys.reduce((obj, k, i) => ({...obj, [k]: vals[i] }), {})
|
||||
|
|
Loading…
Reference in New Issue