get请求
//创建请求实例
const xhr = new XMLHttpRequest
//使用get请求(get为大小写都行)
xhr.open('get', url)
//发送请求
xhr.send()
//监听请求
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
res(xhr.response)
} else {
rej(xhr.status)
}
}
}