MDN

fatch

返回的对象

type string
url string
redirected boolean
status number
ok boolean
statusText string
headers object
body object
bodyUsed boolean
clone function arrayBuffer function
blob function
formData function
json function
text function

get 和 post

        get() {
let headers = new Headers();
headers.append('Content-Type', 'application/json'); let option = {
method: 'GET',
headers: headers,
mode: 'cors',
cache: 'default'
}; let request = new Request('/get', option);
fetch(request).then(res => res.json()).then(res => console.log(res)); post() {
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); let option = {
method: 'POST',
headers: headers,
mode: 'cors',
cache: 'default'
}; let request = new Request('/post', option);
fetch(request).then(res => res.json()).then(res => console.log(res)); }

rxjs的ajax

            rxjs.ajax.ajax.get('/get',{'content-type': 'application/json'})
.pipe(
rxjs.operators.map(res => res.response)
)
.subscribe(
v => { console.log(v) },
e => { console.log(e) },
() => { console.log('complete') }
); rxjs.ajax.ajax.post('/post',{'content-type': 'application/x-www-form-urlencoded;charset=utf-8'})
.pipe(
rxjs.operators.map(res => res.response)
)
.subscribe(
v => { console.log(v) },
e => { console.log(e) },
() => { console.log('complete') }
);

rxjs 包装 fetch

          let get$ = rxjs.from(fetch('/get', {
method: 'GET',
headers: headers
})) get$.pipe( rxjs.operators.mergeMap(res => rxjs.from(res.json())))
.subscribe(res => console.log( res))

并发请求

          let get$ = rxjs.from(fetch('/get', {
method: 'GET',
headers: headers
})) let get1$ = rxjs.from(fetch('/get1', {
method: 'GET',
headers: headers
})) let get2$ = rxjs.from(fetch('/get2', {
method: 'GET',
headers: headers
})) rxjs.merge(get$, get1$, get2$)
.pipe(
rxjs.operators.mergeMap(res => rxjs.from(res.json()))
)
.subscribe(res => console.log(res), err => console.error(err))

最新文章

  1. python 培训之Django
  2. App lifecycle(UWP深入学习一)
  3. 关于一个js连续赋值问题之我见(词略穷,见谅)
  4. html 构建响应式网站之viewport的使用
  5. 移动端 :meta标签1万个作用
  6. 在jsp页面解析json的2种方法
  7. 两个栈实现一个队列,C语言实现,队列可伸缩,容纳任意数目的元素。
  8. 如何在不影响数据库的正常使用的情况下得到数据的完整.mdf和.ldf文
  9. iPhone之为UIView设置阴影(CALayer的shadowColor,shadowOffset,shadowOpacity,shadowRadius,shadowPath属性)
  10. 【转】独立游戏如何对接STEAM SDK
  11. restTemplate.postForObject上传文件中文乱码(???.xls)
  12. [QTree6]Query on a tree VI
  13. SkylineGlobe 移动端开发测试
  14. CoordTools
  15. opencv矩阵操作
  16. JVM JRE JDK三者的区别和联系
  17. 6.JXL操作Excel
  18. [leetcode]Reorder List @ Python
  19. 关于LoadRunner的迭代
  20. 微信公众号支付安卓和WP支付成功,苹果不能支付!

热门文章

  1. nginx+awstats安装过程
  2. 基于Python项目的Redis缓存消耗内存数据简单分析(附详细操作步骤)
  3. testng.xml 配置大全
  4. Linux-文件描述符的本质及与文件指针的区别
  5. fork failed because of Out Of Memory
  6. golang ---tcmalloc浅析
  7. IT? 挨踢
  8. 容器网络——从CNI到Calico
  9. win10安装windows live writer 错误:OnCatalogResult:0x80190194
  10. Clustered Shading架构实现步骤