ES6使用fetch请求数据

ie是完全不支持fetch的。

fetch(url,{method:"get/post"}).then(res=>{   })

如果请求返回的status是200,body是ReadableStream那么,就要使用json()方法转换

例子:

fetch("http://jsonplaceholder.typicode.com/users").then(response => response.json()).then(res=>{
            console.log(res);
        })

猜你喜欢

转载自www.cnblogs.com/luguankun/p/10748430.html
今日推荐