0
我正在使用RxAlamorefire来处理我的应用中的网络任务。如何使用密钥获取json时发出错误
我的问题是:当我提出请求并返回json。如果json有一个键“错误”,我需要发出错误通知,而不是onNext通知。
我的代码是像这样的:
let observable = RxAlamofire.json(.get, url, parameters: nil, encoding: URLEncoding.default, headers: header)
.map { (json) -> SomeObject? in
//Should check json maybe not in ".map" to see if the json contain "error" then emit onError notification.
return Mapper<SomeObject>().map(JSONObject: json)
}