文章标题
来源:互联网 发布:遗传算法的实现 编辑:程序博客网 时间:2024/05/19 14:40
fetch
API
被定义在window对象上,可以用来发起对远程资源的请求,该方法返回的是一个Promise对象,让
var req = new Request(URL, {method: 'GET', cache: 'reload'}); fetch(req).then(function(response) { return response.json(); }).then(function(json) { insertPhotos(json); });
可以基于原有的对象创建一个新的对象
var postReq = new Request(req, {method: 'POST'});
每个Request对象都有一个header属性,在fetchAPI中,它对应了一个Headers对象,通过Headers对象,你能够修改请求头,不仅如此,对于返回的响应,你还能轻松返回响应头的各个属性,但是响应头是只读的
var headers = new Headers(); headers.append('Accept', 'application/json'); var request = new Request(URL, {headers: headers}); fetch(request).then(function(response) { console.log(response.headers); });
阅读全文
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- css知识点总结(2)
- Mysql性能优化-索引
- GCC 参数详解
- nuttx是可抢占式内核
- LSMW批处理使用方法(03)_步骤2
- 文章标题
- jQuery AJAX get() 和 post() 方法示例讲解
- 用react实现对表格增删操作
- 权值并查集——bzoj1202狡猾的商人
- [3]Spring以配置文件的方式进行属性注入
- angular2升级angular4
- 深度学习的硬件方案
- poj ACM1031
- react-native 实现上传功能