I have a very simple question but it has been bouncing all over my head how to handle this. I've been using this API that requires a callback function to capture the values, and i'm having issues in returning the output of the function to other functions that i'm using on my project.
For example:
function a() {
var callback = function(e) {
var id = e.data.responseData.Id;
};
Api.getId(callback);
}
If i try to call the variable id, it will give me undefined so i'm assuming that the id value is not being passed available globally.
On the other side if i run something like this:
function a() {
var callback = function(e) {
var id = e.data.responseData.Id;
console.log(id);
};
Api.getId(callback);
}
It will return me on the console correctly the value of id.
Any ideas on what i'm missing here?
Thanks once again.
Rafa