SOURCE

function Ajax({url = '',method = 'GET'}){
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest()
        xhr.onreadystatechange = function (){
            if(xhr.readyState !== 4) return

            if(xhr.status >=200 && xhr.status < 300){
                resolve(xhr)
            }else{
                reject(xhr)
            }

        }
        xhr.open(method,url,true)
        xhr.send()
    })
}

const asd = Ajax({
    url: 'https://jsonplaceholder.typicode.com/users'
}).then(res => {
    console.log(res.responseText);
});
console 命令行工具 X clear

                    
>
console