如何访问 function .exec(function(err, repl) { 中的响应参数?是否可以不创建局部变量?
#!/usr/local/bin/node
// Load the http module to create an http server.
var http = require('http');
var redis = require('redis');
var client = redis.createClient();
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
client.multi([
['get', 'a'],
['get', 'b']
]).exec(function(err, repl) {
console.log(err);
console.log(repl[0]);
response.end('Repl: ' + repl[0].toString());
});
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");