2
votes

I am trying to integrate Moya which found to be a good framework in designing a network layer. I am stuck in how to retry a network request. Is it possible to get a request variable from Moya provider when we receive an error? Please note, I am looking for an answer in swift not Rxswift

1

1 Answers

0
votes

I faced the same problem. According latest Moya API, there's no way to retrieve network task to be call it again if it fails.
It only returns Cancellable type, which allows you check whether task is executing - isCancelled, or to cancel() request. If you need just urlRequest object, please see this answer for the details. But if you really need to implement "retry" functionality, you have to store route variable and completion closure at your intermediate Moya wrapper and call re-run it when needed.