I need to access the output of a query function outside of that function.
Could anyone help me, please?
This is my code
var params = {
TableName: "myTbl",
ProjectionExpression: "#user_id, level, info.email",
KeyConditionExpression: "#user_id = :ui and level= :l",
ExpressionAttributeNames: {
"#user_id": "user_id"
},
ExpressionAttributeValues: {
":ui": "s123234",
":l": "simple",
}
};
function searchDatabase(params) {
docClient.query(params, function (err, data) {
if (err) {
console.log("Error: ", JSON.stringify(err, null, 2));
} else {
console.log("Results: ", data);
}
});
};
data = searchDatabase(params)
console.log(data);
I need to get the results for the second console.log
. But only the first one (that one inside the function) work properly.