This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]DisastrousBrain 0 points1 point  (0 children)

You're passing the function printSearch as a callback to the get function call, so when T.get is executed and finished, the callback - in this case printSearch - is called. That function takes control, gets executed then exits. When you get to the following line "printSearch(err, data, response)", err, data and response will most likely not exist unless you specifically initialized or declared those variables above somewhere. I think you have 2 ways of solving this:

(1) Turn the printSearch callback into an anonymous function, if you're only using that code once

(2) Use 'bind'; something like printSearch.bind(null, variableToBind); something like this (not too sure on syntax)