With
fileA
userID = (userName) ->
id = 0
someAPI.getUser userName, (err, data, res) ->
id = data.id if data
console.log id # Outputs ID
return
id
console.log userID('someUsername') # Outputs 0
fileB
getUser: (username, callback) ->
return api.get 'users/show', { 'username': username }, callback
how can I get console.log userID('someUsername')
to output the ID as well, instead of 0? I.e. have it wait before returning id.
I have tried randomly wrapping stuff with Meteor.wrapAsync and Meteor.bindEnvironment but can't seem to get anywhere.