In my recursive function, I am trying to return specific data after the function is completed.
// Initializing my Database settings
var coachdb = new AWS.DynamoDB({
...
});
// Keeping track of the current parameter's array index.
var pos = 0;
function callback(err, data) {
if (err) {
console.log(err, err.stack);
} else if (data.Items.length > 0) {
//return data.Items // Need a way to return data here
} else if (++pos < params.length) { // Increasing the index.
coachdb.query(params[pos], callback); // Recursive call.
}
}
coachdb.query(params[pos], callback); // Starting the series of calls
Everything within the function is functioning correctly. The database queries are executed properly, iterating through parameters until the correct one is found, and then the function terminates.
Yet, I am unsure how to pass the data outside of the function. Any assistance on this matter would be greatly appreciated.