fetch已經(jīng)被大部分的瀏覽器兼容了伶唯,包括chrome,F(xiàn)irefox砸民,safari抵怎,opera,edge岭参,但是IE不支持反惕,但是如果想要支持ie,很簡單演侯,有一個很好的工具fetch-ie8姿染,你就可以隨意的遨游在js的美妙的世界中。
const url = 'https://api.github.com/urser/heromen';
fetch(url).then(result => {
return result.json().then(res => {
console.log(res);
});
});
以上是基礎用法