0
function user_id( sessionID )
{
    db
        .where({ session_id: battleData })
        .get('vp_sessions', unserialize);
}

function unserialize(err, results, fields)
{
    var serialized = results[0];
    return PHPUnserialize.unserialize(serialized.user_data);    
}

Is it possible to return the the return value of unserialize?

Secret
  • 3,291
  • 3
  • 32
  • 50
  • 1
    Not if it's asynchronous (and I believe it is). – bfavaretto Jul 24 '13 at 13:35
  • 1
    See [How to return the response from an AJAX call?](http://stackoverflow.com/q/14220321/710446) Of course, you're not using Ajax, but you *are* using an asynchronous API, and the solution is identical. `user_id` cannot sychronously return a value that is acquired asychronously. – apsillers Jul 24 '13 at 13:44

1 Answers1

4

You can only get the return value of a function when you call it. None of the code you have provided calls it.

You pass it to the get method which may call it, but it is up to the code of the get method to do something with the return value.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Ah, I feared as much. If that's the case I might have a bit of a problem in my hands :( Thanks for the reply. – Secret Jul 24 '13 at 13:41