jeudi 16 avril 2015

Pass variable to a promised function

I call an async function that doesn't 'belong' to me inside a loop. I need to get retrieve a variable inside the 'then' function. Here is how I do it:



for(var int = 0; int < attachments.length; int++) {
dp.getAttachment(attachments[int]).then(function (response) {
console.log(int);
});
}


How can I send the int so I can get it inside the function?


Aucun commentaire:

Enregistrer un commentaire