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 () {
|
async list () {
|
||||||
let keys = await this.redis.keys('*')
|
let keys = await this.redis.keys('*')
|
||||||
|
if (keys.length == 0) { return {} }
|
||||||
let vals = await this.redis.mget(keys)
|
let vals = await this.redis.mget(keys)
|
||||||
/* combine list of keys and values into an object */
|
/* combine list of keys and values into an object */
|
||||||
return keys.reduce((obj, k, i) => ({...obj, [k]: vals[i] }), {})
|
return keys.reduce((obj, k, i) => ({...obj, [k]: vals[i] }), {})
|
||||||
|
|
Loading…
Reference in New Issue