Skip to content

Instantly share code, notes, and snippets.

View juulhao's full-sized avatar
👨‍💻
Just do it. After do better!

Julio Rodrigues juulhao

👨‍💻
Just do it. After do better!
View GitHub Profile
@juulhao
juulhao / user.js
Created August 8, 2017 16:39 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);