ajax是一种思想,异步思想
fetch是浏览器亲生的,基于parmise
axios是别人家的孩子,
// axios
axios.get('http://localhost:3000')
.then(response => {
console.log(response.data);
}, error => {
console.log(error);
});
// fetch()
fetch('http://localhost:3000')
.then(response => response.json()) // 额外多了一步
.then(data => {
console.log(data)
})
.catch(error => console.error(error));