...and this may be more of a javascript hiccup than anything else. I have my code working in hype now, but I want to do this on an iteration based on the number of values coming in from SQL which I am hardcoding for y'all for this example. has anyone done anything like what I am attempting and if so can you point me in the right direction? so many times I find myself wanting to write iterative code that will eventually drive the format of and subsequent execution of javascript functions...
here you can see where I am modifying the standard request (xhr) and trying to adapt it to an array iteration xhr_[i] ---- if this syntax is off because of hype, please let me know. i am also bouncing between PHP and javascript a lot, perhaps this is where errors come in. i don't know if I need this syntax let xhr_ + [I] - that particular method seems to break things. and bonus question - who else uses PHP storm to write code for hype and has anyone tried webstorm with hype?
thanks for taking the time to look at this question - I appreciate all of you!
for (let i = 0; i <= numberOfDreams i++) {
return new Promise((resolve, reject) => {
let xhr_[i] = new XMLHttpRequest();
xhr_[i].onreadystatechange = function (evt) {
if (xhr_[i].readyState == 4) {
let res_[i] = JSON.parse(xhr_[i].responseText);
console.log('res: ', res_[i]);
console.log('status:', xhr_[i].status, ' response: ', xhr_[i].responseText);
switch (xhr_[i].status) {
case 200:
let d = res_[i].data;
jwt = d.jwt;
url = d.urls[0];
resolve(d);
break;
default:
reject(res_[i]);
}
}
}
xhr_[i].open("POST", apiPath, true);
xhr_[i].setRequestHeader("Content-Type", "application/json");
xhr_[i].send(JSON.stringify({streamAccountId: accountId, dreamName: dreamName[i], unauthorizedSubscribe: true}));
});
} // end for loop