{"action":"created","issue":{"url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/37","labels_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/37/comments","events_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/37/events","html_url":"https://github.com/matthew-andrews/isomorphic-fetch/issues/37","id":110089139,"number":37,"title":"Interceptors / Default Headers","user":{"login":"lynndylanhurley","id":468037,"avatar_url":"https://avatars.githubusercontent.com/u/468037?v=3","gravatar_id":"","url":"https://api.github.com/users/lynndylanhurley","html_url":"https://github.com/lynndylanhurley","followers_url":"https://api.github.com/users/lynndylanhurley/followers","following_url":"https://api.github.com/users/lynndylanhurley/following{/other_user}","gists_url":"https://api.github.com/users/lynndylanhurley/gists{/gist_id}","starred_url":"https://api.github.com/users/lynndylanhurley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lynndylanhurley/subscriptions","organizations_url":"https://api.github.com/users/lynndylanhurley/orgs","repos_url":"https://api.github.com/users/lynndylanhurley/repos","events_url":"https://api.github.com/users/lynndylanhurley/events{/privacy}","received_events_url":"https://api.github.com/users/lynndylanhurley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-06T20:05:44Z","updated_at":"2015-10-07T07:13:28Z","closed_at":null,"body":"I'm trying to include an auth header in each request to my API. \r\n\r\nI can do this with jQuery.ajax using `beforeSend`, and AngularJS has something called [interceptors](https://docs.angularjs.org/api/ng/service/$http#interceptors) which make it really easy.\r\n\r\nBut I can't figure out how to do this using `fetch`. Any ideas?"},"comment":{"url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/comments/146098244","html_url":"https://github.com/matthew-andrews/isomorphic-fetch/issues/37#issuecomment-146098244","issue_url":"https://api.github.com/repos/matthew-andrews/isomorphic-fetch/issues/37","id":146098244,"user":{"login":"matthew-andrews","id":825088,"avatar_url":"https://avatars.githubusercontent.com/u/825088?v=3","gravatar_id":"","url":"https://api.github.com/users/matthew-andrews","html_url":"https://github.com/matthew-andrews","followers_url":"https://api.github.com/users/matthew-andrews/followers","following_url":"https://api.github.com/users/matthew-andrews/following{/other_user}","gists_url":"https://api.github.com/users/matthew-andrews/gists{/gist_id}","starred_url":"https://api.github.com/users/matthew-andrews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthew-andrews/subscriptions","organizations_url":"https://api.github.com/users/matthew-andrews/orgs","repos_url":"https://api.github.com/users/matthew-andrews/repos","events_url":"https://api.github.com/users/matthew-andrews/events{/privacy}","received_events_url":"https://api.github.com/users/matthew-andrews/received_events","type":"User","site_admin":false},"created_at":"2015-10-07T07:13:28Z","updated_at":"2015-10-07T07:13:28Z","body":"Why don't you make a new function?\r\n\r\n```js\r\nfunction makeAuthenticatedRequest(url, opts) {\r\n  opts.headers = opts.headers || {};\r\n  opts.header.Authorization = \"a-secret\";\r\n  return fetch(url, opts);\r\n}\r\n```\r\n\r\nthen use that?"}}