有什么方法可以编写一个从回调函数返回数据的函数。 以下是我的代码,输出和预期功能 https://github.com/NodeRedis/node_redis#usage-example
// Code
var redis = require("redis"),
client = redis.createClient();
client.set("string key", "London");
client.get("string key", function(err,data){console.log(data)});
client.quit();
// Ouput
London
//Expectations: Below getData() Function should return outut London
function getData() {
client.get("string key", function(err,data){return data});
}
Extract from NodeRedis code where get which returns bollean value amd Callback function returns actual value
// get(key: string, cb?: Callback<string>): R;