{"action":"opened","issue":{"url":"https://api.github.com/repos/bitinn/node-fetch/issues/483","repository_url":"https://api.github.com/repos/bitinn/node-fetch","labels_url":"https://api.github.com/repos/bitinn/node-fetch/issues/483/labels{/name}","comments_url":"https://api.github.com/repos/bitinn/node-fetch/issues/483/comments","events_url":"https://api.github.com/repos/bitinn/node-fetch/issues/483/events","html_url":"https://github.com/bitinn/node-fetch/issues/483","id":340257046,"node_id":"MDU6SXNzdWUzNDAyNTcwNDY=","number":483,"title":"PreFetch / PostFetch callbacks","user":{"login":"FabianTe","id":7669818,"node_id":"MDQ6VXNlcjc2Njk4MTg=","avatar_url":"https://avatars1.githubusercontent.com/u/7669818?v=4","gravatar_id":"","url":"https://api.github.com/users/FabianTe","html_url":"https://github.com/FabianTe","followers_url":"https://api.github.com/users/FabianTe/followers","following_url":"https://api.github.com/users/FabianTe/following{/other_user}","gists_url":"https://api.github.com/users/FabianTe/gists{/gist_id}","starred_url":"https://api.github.com/users/FabianTe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FabianTe/subscriptions","organizations_url":"https://api.github.com/users/FabianTe/orgs","repos_url":"https://api.github.com/users/FabianTe/repos","events_url":"https://api.github.com/users/FabianTe/events{/privacy}","received_events_url":"https://api.github.com/users/FabianTe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-11T14:04:12Z","updated_at":"2018-07-11T14:04:12Z","closed_at":null,"author_association":"NONE","body":"Hi!\r\n\r\nTIL: I would like to be able to call my code (via callback) before and after requests, especially on **redirect** responses.\r\n\r\nCurrently I am using this package to create automated tests that call some microservices. Those are secured and the user has to be authorized via a cookie. For this I am using `tough-cookie` which works fine by itself. Am am using it to insert cookie headers before `fetch` requests and it is storing received cookies from `Response` instances via the `set-cookie` header.\r\n\r\nThis does not work for server responses that want the client to redirect. `node-fetch` is able to follow redirects, yes, but I am not able to store cookies from the pages that were received while in the redirect loop.\r\n\r\nUsing redirect manually is just such a hassle. Hence I though that it would be useful to have some callbacks which enable me to do X before **every** request - manipulating the request parameters / setting cookies - and to do Y after **every** response was received. Important thing, this would have to apply to redirects.\r\n\r\nAny thoughts?"}}
{"actor":{"display_login":"FabianTe"}}