I am using Moya in my swift app for network requests.
I have used alamofire earlier and I am familiar with how to make post, get requests and read the response .
Following is the code where I am making a request and subscribing to the observable
provider.request(.getDetails)
.mapArray(Post.self)
.subscribe { event -> Void in
switch event {
case .next(let post):
self.sampleText.text = posts.first?.title
case .error(let error):
print(error)
default:
break
}
}.addDisposableTo(disposeBag)
In the .next case I also want to retrieve the status code and response.data.
I am able to do so when the observable is of type Response but when I map it to type Post I cannot get the status code.
How can I get the status code of the request in .next or error case
Any help will be appreciated. Thank you.