RxJS 操作符 - ajax 发起异步请求

import { ajax } from 'rxjs/ajax'
import { map } from 'rxjs'

ajax({
  url: 'https://httpbin.org/delay/2',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: 'Hello, World!',
})
  .pipe(map(res => res.response.data))
  .subscribe(console.log) // Hello World!

posted on 2022-07-06 14:11  aisowe  阅读(214)  评论(0编辑  收藏  举报

导航