将缓冲区转换为Redis中的string获取Node.js Heroku应用程序
这是我非常基本的GETfunction
app.get('/', function(request, response) { response.contentType('application/json'); var lid = request.param("lid"); client.llen(lid, function(reply, len){ client.lrange(lid, 0, len-1, function(reply, messages){ console.log(messages); response.send(messages); }) }); });
出于某种原因,控制台输出和我得到的响应看起来像
[ <Buffer 5b 7b 22 6c 61 77 79 65 72 5f ... 61 64 61 74 61 22 3a 22 36 22 7d 5d> ]
我将这些存储为JSONstring:
client.lpush(lid, JSON.stringify(to_store))
任何想法,为什么我的回应不是一个JSONstring?
谢谢。
尝试
console.log(messages.toString());