Skip to content

Instantly share code, notes, and snippets.

@objectiveSee
Created August 16, 2013 01:42
Show Gist options
  • Save objectiveSee/6246542 to your computer and use it in GitHub Desktop.
Save objectiveSee/6246542 to your computer and use it in GitHub Desktop.
How can I save the value of foo from changing code in this function only?
if(request.args.game_id === undefined) {
var foo = undefined;
Game.transactById(request.args.game_id, function(err, game) {
foo = game.participantDiscards(request.getUserId(), request.args.card_id_array);
}, function(err, game) {
if(err) {
request.onError(err);
} else {
// HERE I WANT ACCESS TO foo BUT IT IS UNDEFINED HERE YET DEFINED INSIDEtransactById
request.onSuccess(foo);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment