Skip to content

Commit

Permalink
add retry to middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
vetrek committed Mar 26, 2024
1 parent 39ce44f commit 1f45fa7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/Core/ApiClient+Closure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,11 @@ extension ApiClient {
request: URLRequest,
queue: DispatchQueue = .main,
progressHUD: SNProgressHUD? = nil,
retryCount: Int = 0,
completion: @escaping (Response<Data>) -> Void
) -> NetworkCancellable? {
guard retryCount < 2 else { return nil }

let task = session?.dataTask(
with: request
) { (data, response, error) in
Expand Down Expand Up @@ -311,6 +314,7 @@ extension ApiClient {
request: request,
queue: queue,
progressHUD: progressHUD,
retryCount: retryCount + 1,
completion: completion
)
return
Expand All @@ -328,6 +332,7 @@ extension ApiClient {
request: request,
queue: queue,
progressHUD: progressHUD,
retryCount: retryCount + 1,
completion: completion
)
return
Expand Down

0 comments on commit 1f45fa7

Please sign in to comment.