HTTP Request

Promises and async/await:

const fetchData = () => {
    fetch('https://api-github.com') //to get data
    .then(resp => {            //.then method to return json object
         resp.json().then(data => { //to parse raw data on resp object
         console.log(data);
         });
     });
}

Modern way:

const fetchData = async () => {
     const resp = await fetch('https://api-github.com');
     const data = await resp.json();
     console.log(data);
};
fetchData();
var xhr = new XMLHttpRequest();    
xhr.open("GET", "https://reqres.in/api/unknown", true);   
xhr.onload = function () {   
console.log(xhr.responseText, xhr.responseType);    
};    
xhr.send();