I have a scenario where I am using a method that sends a POST
request and then triggers a specific callback function to manage the response:
myService.verify(id, verificationCallback);
function verificationCallback(err, response) { ... }
My query is two-fold. It appears that there are 2 hidden arguments being passed to verificationCallback
(is this accurate and how does it function?)
If I wanted to introduce a third argument to that callback, how would I go about doing so? Would this approach work:
myService.verify(id, verificationCallback(err, response, someOtherArgument));
Is this likely to cause an issue because the err
and response
variables are not defined in the current context? Should I access these variables using the arguments
object?
Potential Resolution (?)
One possible way could be to use an anonymous function:
myService.verify(id, function(err, response) {
// Access the additional variable here
someOtherArgument === ...
});
Thank you