I'm trying to create a function that accepts a channel as a parameter.
The function takes the parameter and searches for the channel in mongodb. I need to return the data so that I can access it outside of the function.
I know what I'm doing wrong, the problem is I don't know how to fix it, and after spending the last 3 hours trying to do so I've given up and came here.
Here's the code:
var getStream = function(channel) {
Stream.find({'channel': channel}, function(err, data) {
if (err) throw err;
console.log(data);
// How do I return this data??
});
};
console.log(getStream('summit5g')); <-- undefined