I think this is a pretty common use case, but I couldn't find any best way to achieve it.
Some parts of my ios application require login. How do I achieve the following pattern using Alamofire and swift.
.request (.GET 'login_required_endpoint')
.responsejson(if statusCode == 401){
login()
continue with GETing
login_required_endpoint
What is the best way to achieve this.
- Make a request
- If server responds with 401(Unauthorized)
- Ask user to login after saving all the request payload for previous request
- After successful login, continue with request in [1] with payload saved
(I realize it is open-ended, but any help on how to make progress would be highly appreciated)