我想使用RxAlamofire进行 post 调用,它提供了函数 requestJson,它需要两个参数 类型 get 或 post 和 url但是没有参数来传递 post json body如何做到以下是我的代码
var components = URLComponents(string: url)!
components.setQueryItems(with: param)
let url = components.url!
print("\(url)")
RxAlamofire.requestJSON(.post, url)
.subscribe(onNext: { [weak self] (r, json) in
if let jsonResult = JSON(json) as? JSON {
if let cartResult = FoodCartResult(jsonResult) as? FoodCartResult {
self?.delegate?.showCart(cartresult: cartResult)
}
}
}, onError: { [weak self] (error) in
print(error.localizedDescription)
self?.delegate?.onError()
},onCompleted: {})
.disposed(by: disposeBag)