Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 0632347878/4014f1adf377c9c896baf5c7ed705b20 to your computer and use it in GitHub Desktop.
Save 0632347878/4014f1adf377c9c896baf5c7ed705b20 to your computer and use it in GitHub Desktop.
Custom get httpRequest
function customGet ( url, cb ) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(xmlhttp.response);
cb(data);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
customGet('./ajax_info.json', function ( response ) {
var all = 0;
for (var key = 0; key < response.length; key++) {
console.log('key', key, '\ndata', response[key]);
all += response[key].age;
}
});
@0632347878
Copy link
Author

 axios.get(this.url)
                    .then(response => response.data)
                    .then(response => {
                    this.employees = response
            })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment