{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-js/issues/701","repository_url":"https://api.github.com/repos/swagger-api/swagger-js","labels_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/701/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/701/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/701/events","html_url":"https://github.com/swagger-api/swagger-js/issues/701","id":128616021,"number":701,"title":"Allow for async actions before API requests","user":{"login":"bendavis78","id":324392,"avatar_url":"https://avatars.githubusercontent.com/u/324392?v=3","gravatar_id":"","url":"https://api.github.com/users/bendavis78","html_url":"https://github.com/bendavis78","followers_url":"https://api.github.com/users/bendavis78/followers","following_url":"https://api.github.com/users/bendavis78/following{/other_user}","gists_url":"https://api.github.com/users/bendavis78/gists{/gist_id}","starred_url":"https://api.github.com/users/bendavis78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendavis78/subscriptions","organizations_url":"https://api.github.com/users/bendavis78/orgs","repos_url":"https://api.github.com/users/bendavis78/repos","events_url":"https://api.github.com/users/bendavis78/events{/privacy}","received_events_url":"https://api.github.com/users/bendavis78/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-25T19:23:44Z","updated_at":"2016-02-09T01:04:44Z","closed_at":null,"body":"Use case: it's good to check for for expired tokens before every API request, and refreshing tokens is an asynchronous operation. Right now I have to have this before every api call:\r\n\r\n    checkExpired().then(function() {\r\n        return client.default.createSomething(params);\r\n    });\r\n\r\nIt would be ideal if I could intercept requests asynchronously."},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-js/issues/comments/181651774","html_url":"https://github.com/swagger-api/swagger-js/issues/701#issuecomment-181651774","issue_url":"https://api.github.com/repos/swagger-api/swagger-js/issues/701","id":181651774,"user":{"login":"bendavis78","id":324392,"avatar_url":"https://avatars.githubusercontent.com/u/324392?v=3","gravatar_id":"","url":"https://api.github.com/users/bendavis78","html_url":"https://github.com/bendavis78","followers_url":"https://api.github.com/users/bendavis78/followers","following_url":"https://api.github.com/users/bendavis78/following{/other_user}","gists_url":"https://api.github.com/users/bendavis78/gists{/gist_id}","starred_url":"https://api.github.com/users/bendavis78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendavis78/subscriptions","organizations_url":"https://api.github.com/users/bendavis78/orgs","repos_url":"https://api.github.com/users/bendavis78/repos","events_url":"https://api.github.com/users/bendavis78/events{/privacy}","received_events_url":"https://api.github.com/users/bendavis78/received_events","type":"User","site_admin":false},"created_at":"2016-02-09T01:04:44Z","updated_at":"2016-02-09T01:04:44Z","body":"I tried `requestInterceptor`, but `SwaggerHttp` [doesn't wait](https://github.com/swagger-api/swagger-js/blob/4aab2557a6625cbf800f05d0f121f8cc56817ba7/lib/http.js#L92) for anything before sending the request.\r\n\r\nThe object being passed around has a `deferred` property, but that's a promise for the response. I need the client to wait on a promise for something that's needed before the request."}}