JSFiddle - React, Tailwind, and code Playground
JavaScript
const xhr = new XMLHttpRequest(),
method = "GET",
url = "https://jsonplaceholder.typicode.com/todos/";
xhr.open(method, url, false);
xhr.onreadystatechange = function () {
if(xhr.readyState === XMLHttpRequest.DONE) {
var status = xhr.status;
if (status === 0 || (status >= 200 && status < 400)) {
// The request has been completed successfully
console.log(xhr.responseText);
} else {
// Oh no! There has been an error with the request!
}
}
};
console.log("****1*****");
xhr.send();
console.log("****2*****");
console.log(xhr.response)