如何使用 RxSwift 和 alamofire 获得嵌套 api 调用的响应?在这里,我得到了来自 alamofire api cal 的响应,因此我需要调用另一个 api 调用。我想获得第二个 api 调用响应。谁能建议我解决这个问题的解决方案。请。
func origin() -> Observable<String> {
return Alamofire.request("httpbin.org/get").rx.responseJSON()
}
func otherApiCall(with origin: String) -> Observable<YourType> {
// Other api call using origin
return Alamofire...........
}
然后
origin()
.flatMap{ origin in
otherApiCall(with: origin)
}
.subscribe(onNext: { response in
})
.disposed(by: disposeBag)