-
-
Notifications
You must be signed in to change notification settings - Fork 154
Allow arbitrary non-Siesta promises in request chains #152
Copy link
Copy link
Closed
Description
Hello,
I'm trying to implement this example: http://bustoutsolutions.github.io/siesta/guide/configuration/#decorating-requests-via-configuration
But getting into trouble , cause I'm getting the new token async, so don't see how I should make that code work. This is how far I have gotten:
func refreshTokenOnAuthFailure(request: Request) -> Request {
return request.chained {
guard case .failure(let error) = $0.response, // Did request fail…
error.httpStatusCode == 401 else { // …because of expired token?
return .useThisResponse // If not, use the response we got.
}
if let refreshToken = self.authService.getRefreshToken(){
self.authService.fetchNewToken(refreshToken:refreshToken).then { token -> Void in
//Async stuff , how should I do to retry the request here ? <-- problem here
// callback request.repeated()
}.catch {error in
//also .useThisResponse.
}
}
return .useThisResponse;
}
}
So this code does kinda nothing. I have looked at the closest issues also but don't really see an solution to my problem.
Anyway that could guide me in the right direction ? :)
Just a FYI: I'm kinda new to Swift/iOS dev, so maybe I'm missing something obvious.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels