{"action":"reopened","issue":{"url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/issues/28","repository_url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter","labels_url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/issues/28/comments","events_url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/issues/28/events","html_url":"https://github.com/RasCarlito/axios-cache-adapter/issues/28","id":304204221,"number":28,"title":"transformResponse behaviour","user":{"login":"gonstr","id":1374839,"avatar_url":"https://avatars3.githubusercontent.com/u/1374839?v=4","gravatar_id":"","url":"https://api.github.com/users/gonstr","html_url":"https://github.com/gonstr","followers_url":"https://api.github.com/users/gonstr/followers","following_url":"https://api.github.com/users/gonstr/following{/other_user}","gists_url":"https://api.github.com/users/gonstr/gists{/gist_id}","starred_url":"https://api.github.com/users/gonstr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonstr/subscriptions","organizations_url":"https://api.github.com/users/gonstr/orgs","repos_url":"https://api.github.com/users/gonstr/repos","events_url":"https://api.github.com/users/gonstr/events{/privacy}","received_events_url":"https://api.github.com/users/gonstr/received_events","type":"User","site_admin":false},"labels":[{"id":692205172,"url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/labels/bug","name":"bug","color":"ee0701","default":true},{"id":692205175,"url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/labels/help%20wanted","name":"help wanted","color":"33aa3f","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/milestones/3","html_url":"https://github.com/RasCarlito/axios-cache-adapter/milestone/3","labels_url":"https://api.github.com/repos/RasCarlito/axios-cache-adapter/milestones/3/labels","id":2898098,"number":3,"title":"2.1.0","description":"","creator":{"login":"RasCarlito","id":407268,"avatar_url":"https://avatars1.githubusercontent.com/u/407268?v=4","gravatar_id":"","url":"https://api.github.com/users/RasCarlito","html_url":"https://github.com/RasCarlito","followers_url":"https://api.github.com/users/RasCarlito/followers","following_url":"https://api.github.com/users/RasCarlito/following{/other_user}","gists_url":"https://api.github.com/users/RasCarlito/gists{/gist_id}","starred_url":"https://api.github.com/users/RasCarlito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RasCarlito/subscriptions","organizations_url":"https://api.github.com/users/RasCarlito/orgs","repos_url":"https://api.github.com/users/RasCarlito/repos","events_url":"https://api.github.com/users/RasCarlito/events{/privacy}","received_events_url":"https://api.github.com/users/RasCarlito/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":1,"state":"open","created_at":"2017-11-08T19:00:58Z","updated_at":"2018-03-20T09:10:38Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2018-03-11T23:14:49Z","updated_at":"2018-03-20T09:10:38Z","closed_at":null,"author_association":"NONE","body":"When you supply a function to the axios transformResponse config, the function gets called both before the response gets cached, and when a response is retrieved from the cache later, which causes code like this to fail:\r\n\r\n```js\r\nconst http = axios.create({ adapter: cache.adapter })\r\n\r\nconst callApi = () => http.get('https://abc.com/api', {\r\n  transformResponse: [data => {\r\n    return data.a + data.b\r\n  }]\r\n})\r\n\r\nawait callApi()\r\nawait callApi()\r\n```\r\n\r\nThe two calls to callApi() will return different data since it runs transformResponse on the cached response. You need to write code like this for it to work:\r\n\r\n```js\r\nconst http = axios.create({ adapter: cache.adapter })\r\n\r\nconst callApi = () => http.get('https://abc.com/api', {\r\n  transformResponse: [data => {\r\n    if (data.transformed) return data\r\n    return { transformed: true, value: data.a + data.b }\r\n  }]\r\n})\r\n```\r\n\r\nIt's great that you can transform a response before caching it but is there any way to get axios to not run transform again on already cached responses?"}}
{"actor":{"display_login":"RasCarlito"}}