{"action":"created","issue":{"url":"https://api.github.com/repos/Moya/Moya/issues/748","repository_url":"https://api.github.com/repos/Moya/Moya","labels_url":"https://api.github.com/repos/Moya/Moya/issues/748/labels{/name}","comments_url":"https://api.github.com/repos/Moya/Moya/issues/748/comments","events_url":"https://api.github.com/repos/Moya/Moya/issues/748/events","html_url":"https://github.com/Moya/Moya/issues/748","id":185840350,"number":748,"title":"What's the best way to chain requests that are dependent on one another using RxMoya?","user":{"login":"rlam3","id":1154044,"avatar_url":"https://avatars.githubusercontent.com/u/1154044?v=3","gravatar_id":"","url":"https://api.github.com/users/rlam3","html_url":"https://github.com/rlam3","followers_url":"https://api.github.com/users/rlam3/followers","following_url":"https://api.github.com/users/rlam3/following{/other_user}","gists_url":"https://api.github.com/users/rlam3/gists{/gist_id}","starred_url":"https://api.github.com/users/rlam3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlam3/subscriptions","organizations_url":"https://api.github.com/users/rlam3/orgs","repos_url":"https://api.github.com/users/rlam3/repos","events_url":"https://api.github.com/users/rlam3/events{/privacy}","received_events_url":"https://api.github.com/users/rlam3/received_events","type":"User","site_admin":false},"labels":[{"id":122272862,"url":"https://api.github.com/repos/Moya/Moya/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":23,"created_at":"2016-10-28T05:13:27Z","updated_at":"2016-12-08T18:26:54Z","closed_at":null,"body":"I need to perform the following steps in order for my service to work:\n1. GET csrf_token\n2. Set csrf_token + jwt into http header\n3. Return the response \n\nIs there a specific way where my endpoint enclosure is able to do a `GET` request using the same provider? Or would I need to invoke another provider within the endpoint enclosure to invoke another request to do my GET request?\n\n``` swift\nlet endpointClosure = { (target: GameAppMoyaAPI) -> Endpoint<GameAppMoyaAPI> in\n\n        let endpoint: Endpoint<GameAppMoyaAPI> = Endpoint<GameAppMoyaAPI>(\n            URL: target.baseURL.URLByAppendingPathComponent(target.path).absoluteString,\n            sampleResponseClosure: {.NetworkResponse(200, target.sampleData)},\n            method: target.method,\n            parameters: target.parameters,\n            parameterEncoding: target.encoding\n        )\n\n        switch target {\n        case .AuthenticateUser:\n            return endpoint\n        default:\n\n            // 1. Check if token is expired from Locksmith\n            // 2. If expired, GET new access_token with refresh_token\n            // 3. Write new access_token back into Locksmith\n            // 4. Else, add token from Locksmith to Header\n\n            let dict = Locksmith.loadDataForUserAccount()\n\n            // FIXME: This is temporarily in\n            let access_token = dict![\"jwt_token\"] as! String\n\n            // Need to add csrf_token to header for POST\n            if target.method == .POST{\n\n                // Would I be invoking another provider here?\n\n                let csrf = ???\n\n\n                return endpoint.endpointByAddingHTTPHeaderFields(\n                [\n                  \"Authorization\": \"Bearer \\(access_token)\", \n                  \"X-CSRFToken\": csrf\n                ])\n\n            }\n\n            return endpoint.endpointByAddingHTTPHeaderFields([\"Authorization\": \"Bearer \\(access_token)\"])\n\n        }\n    }\n\n\nlet provider = RxMoyaProvider<MyMoyaAPI>(endpointClosure:endpointClosure)\n\nprovider.request(.PostRequest(parameter:some_parameter))\n.subscribe{\n...\n}\n\n\n```\n\nThanks!\n"},"comment":{"url":"https://api.github.com/repos/Moya/Moya/issues/comments/265815478","html_url":"https://github.com/Moya/Moya/issues/748#issuecomment-265815478","issue_url":"https://api.github.com/repos/Moya/Moya/issues/748","id":265815478,"user":{"login":"AndrewSB","id":3814772,"avatar_url":"https://avatars.githubusercontent.com/u/3814772?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewSB","html_url":"https://github.com/AndrewSB","followers_url":"https://api.github.com/users/AndrewSB/followers","following_url":"https://api.github.com/users/AndrewSB/following{/other_user}","gists_url":"https://api.github.com/users/AndrewSB/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewSB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewSB/subscriptions","organizations_url":"https://api.github.com/users/AndrewSB/orgs","repos_url":"https://api.github.com/users/AndrewSB/repos","events_url":"https://api.github.com/users/AndrewSB/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewSB/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T18:26:54Z","updated_at":"2016-12-08T18:26:54Z","body":"@rlam3 I renamed this issue to reflect what the discussion turned into, I hope that's alright with you, please let me know if I should change it back or change it to something else 🙃"}}
{"actor":{"display_login":"AndrewSB"}}