SOURCE

function axios(method,url,data){
    return new Promise((resolve, reject)=>{
        const xhr = new XMLHttpRequest()
        //打开一个 http请求并,传入方法和url
        xhr.open(method,url)
        console.log(xhr)
        xhr.onreadystatechange = ()=>{
            console.log(xhr.readyState)
            if(xhr.readyState !== 4){
                return
            }
            if(xhr.status === 200){
                console.log('success')
                resolve(xhr.response)
            }else{
                console.log('error')
                reject(xhr.statusText)
            }
        }
        xhr.send(data)
    })
}

// const res = new axios('POST','www.baidu.com','hello baidu')

console 命令行工具 X clear

                    
>
console