diff --git a/red/api/admin/context.js b/red/api/admin/context.js index ef23a26ea..b99221dc4 100644 --- a/red/api/admin/context.js +++ b/red/api/admin/context.js @@ -50,15 +50,19 @@ module.exports = { ctx.keys(function(err, keys) { var result = {}; var c = keys.length; - keys.forEach(function(key) { - ctx.get(key,function(err, v) { - result[key] = util.encodeObject({msg:v}); - c--; - if (c === 0) { - res.json(result); - } + if (c === 0) { + res.json(result); + } else { + keys.forEach(function(key) { + ctx.get(key,function(err, v) { + result[key] = util.encodeObject({msg:v}); + c--; + if (c === 0) { + res.json(result); + } + }); }); - }); + } }); } } else {