fetch‘是浏览器自带的,不用引入第三方库,底层逻辑不是xhl,关注分离,返回的是promise对象
一、未优化写法
fetch(url).then(
(respone)=>{
return respone.json()
}
(error)=>{}
).then(
data=>{}
erroe=>{}
)
二、优化写法
async function sendFetch(){
try(
const respones = await fetch(url)
const data = await respones.json()
)catch(error){}