Ajax add several users to letter Api trello

0

I explain my case: I am generating three letters by tagging several users, each user has his "code" for example (5891c93eb1cyl471ee1fe47c) I have a function that adds 5 users (this function is called from another) the case is that I'm doing a POST to the api for each user, although I do it perfectly I think it should be done in another way ** Any ideas? ** what I use:

 var datas = null;
var usuRQ1 = new XMLHttpRequest();
usuRQ1.open("POST", "https://api.trello.com/1/cards/" + data + "/idMembers?value=" + usuario1RRHH + "&key=" + appkeyRRHH + "&token=" + tokenRRHH);
usuRQ1.send(datas);

var usuRQ2 = new XMLHttpRequest();
usuRQ2.open("POST", "https://api.trello.com/1/cards/" + data + "/idMembers?value=" + usuario2RRHH + "&key=" + appkeyRRHH + "&token=" + tokenRRHH);
usuRQ2.send(datas);


var usuRQ3 = new XMLHttpRequest();
usuRQ3.open("POST", "https://api.trello.com/1/cards/" + data + "/idMembers?value=" + usuario3RRHH + "&key=" + appkeyRRHH + "&token=" + tokenRRHH);
usuRQ3.send(datas);


var usuRQ4 = new XMLHttpRequest();
usuRQ4.open("POST", "https://api.trello.com/1/cards/" + data + "/idMembers?value=" + usuario4RRHH + "&key=" + appkeyRRHH + "&token=" + tokenRRHH);
usuRQ4.send(datas);


var usuRQ5 = new XMLHttpRequest();
usuRQ5.open("POST", "https://api.trello.com/1/cards/" + data + "/idMembers?value=" + usuario5RRHH + "&key=" + appkeyRRHH + "&token=" + tokenRRHH);
usuRQ5.send(datas);
    
asked by Yasiel Hernández 29.05.2018 в 09:54
source

1 answer

0

Self solved. If you have any other idea I appreciate it

var ArrUsuarios = [usuario1RRHH,usuario2RRHH,usuario3RRHH,usuario4RRHH,usuario5RRHH ]
var arrRQ = [];
var datas = null;
var usuRQ1 = new XMLHttpRequest();
for (let i = 0; i < ArrUsuarios.length; i++) {
    usuRQ1.open("POST", "https://api.trello.com/1/cards/" + data + "/idMembers?value=" + ArrUsuarios[i] + "&key=" + appkeyRRHH + "&token=" + tokenRRHH);
    usuRQ1.send(datas);
}
    
answered by 29.05.2018 в 10:02