var p1 = new Promise((resolve, reject) => {
setTimeout(resolve, 200, "foo2");
});
var p2 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, "foo1");
});
Promise.all([p1, p2]).then(values => {
console.log(values);
});
var obj = getBelts(beltObj);
console.log('наш массив ' + obj); //undefined
function getBelts() {
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest();
request.open('GET', 'api/belts/', true);
request.onreadystatechange = function() {
if (request.readyState === 4 && request.status === 200) {
var beltsArr = JSON.parse(request.responseText);
resolve(beltsArr)
}
}
request.send();
}
}
var obj = getBelts();
obj.then(function(array){
console.log(array);
return array;
})
php pool www.conf
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data