1. 特點
???1.fetch: 原生函數(shù)货抄,不再使用XmlHttpRequest對象提交ajax請求
???2.老版本瀏覽器可能不支持
2.相關(guān)API
- GET 請求
fetch(url).then(response => {
return response.json()
}).then(data => {
console.log(data)
}).catch(e => {
console.log(e)
});
- POST 請求
fetch(url, {
method: "POST",
body: JSON.stringify(data),
}).then(data => {
console.log(data)
}).catch(e => {
console.log(e)
})