{"action":"opened","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/8242","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/8242/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/8242/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/8242/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/8242","id":327186421,"number":8242,"title":"[Javascript] How can I intercept the response to handle customzied exceptions?","user":{"login":"zeroarst","id":1834837,"avatar_url":"https://avatars1.githubusercontent.com/u/1834837?v=4","gravatar_id":"","url":"https://api.github.com/users/zeroarst","html_url":"https://github.com/zeroarst","followers_url":"https://api.github.com/users/zeroarst/followers","following_url":"https://api.github.com/users/zeroarst/following{/other_user}","gists_url":"https://api.github.com/users/zeroarst/gists{/gist_id}","starred_url":"https://api.github.com/users/zeroarst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeroarst/subscriptions","organizations_url":"https://api.github.com/users/zeroarst/orgs","repos_url":"https://api.github.com/users/zeroarst/repos","events_url":"https://api.github.com/users/zeroarst/events{/privacy}","received_events_url":"https://api.github.com/users/zeroarst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-29T06:35:25Z","updated_at":"2018-05-29T06:35:25Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nPlease follow the issue template below for bug reports and feature requests.\r\nAlso please indicate in the issue title which language/library is concerned. Eg:  [JAVA] Bug generating foo with bar \r\n-->\r\n\r\n##### Description\r\n\r\nI want to register a global interceptor to handle the response. We have customized error code that will return as a Http 200 successful response.\r\nI have checked the source code I found there is a line of code: this.requestAgent = null;.\r\nThen I did below\r\n```javascript\r\nlet Agent = require('superagent');\r\nlet agent = new Agent().use((reqequest) => {\r\n  console.log(request);\r\n  request.on('response', function(response) {\r\n    console.log(response.mydata.responseCode);\r\n    return request;\r\n  })\r\n});\r\nconst myService= require('@myService');\r\nmyService.ApiClient.instance.requestAgent = agent;\r\n```\r\n\r\nI can see the reqequest from the console, means it got called. but never get the response. If I add `.end` it calls the API, However, the URL is ttp://localhost:8080/undefined. \r\n\r\nI think I didn't do it correctly. Can any one show me an example to how to intercept the response??\r\n\r\n##### Swagger-codegen version\r\n\r\n2.3.1\r\n\r\n##### Swagger declaration file content or url\r\n\r\n<!-- if it is a bug, a json or yaml that produces it.\r\nIf you post the code inline, please wrap it with\r\n```yaml\r\n(here your code)\r\n```\r\n(for YAML code) or\r\n```json\r\n(here your code)\r\n```\r\n(for JSON code), so it becomes more readable. If it is longer than about ten lines,\r\nplease create a Gist (https://gist.github.com) or upload it somewhere else and\r\nlink it here.\r\n  -->\r\n\r\n##### Command line used for generation\r\n\r\n<!-- including the language, libraries and various options -->\r\n\r\n##### Steps to reproduce\r\n\r\n<!-- unambiguous set of steps to reproduce the bug.-->\r\n\r\n##### Related issues/PRs\r\n\r\n<!-- has a similar issue/PR been reported/opened before? Please do a search in https://github.com/swagger-api/swagger-codegen/issues?utf8=%E2%9C%93&q=is%3Aissue%20 -->\r\n\r\n##### Suggest a fix/enhancement\r\n\r\n<!-- if you can't fix the bug yourself, perhaps you can point to what might be\r\n  causing the problem (line of code or commit), or simply make a suggestion -->\r\n\r\n"}}
{"actor":{"display_login":"zeroarst"}}