function getBelts() {
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);
beltObj(beltsArr)
}
}
request.send();
}
function beltObj(obj){
return obj;
}
var beltObj = getBelts();
console.log(beltObj);
function getBelts(callback) {
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);
callback(beltsArr)
}
}
request.send();
}
function beltObj(array){
console.log(array);
return array;
}
getBelts(beltObj);