{"action":"created","issue":{"url":"https://api.github.com/repos/moul/node-slumber/issues/4","labels_url":"https://api.github.com/repos/moul/node-slumber/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/moul/node-slumber/issues/4/comments","events_url":"https://api.github.com/repos/moul/node-slumber/issues/4/events","html_url":"https://github.com/moul/node-slumber/issues/4","id":67605073,"number":4,"title":"Modifying headers","user":{"login":"kevinkhill","id":266076,"avatar_url":"https://avatars.githubusercontent.com/u/266076?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinkhill","html_url":"https://github.com/kevinkhill","followers_url":"https://api.github.com/users/kevinkhill/followers","following_url":"https://api.github.com/users/kevinkhill/following{/other_user}","gists_url":"https://api.github.com/users/kevinkhill/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinkhill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinkhill/subscriptions","organizations_url":"https://api.github.com/users/kevinkhill/orgs","repos_url":"https://api.github.com/users/kevinkhill/repos","events_url":"https://api.github.com/users/kevinkhill/events{/privacy}","received_events_url":"https://api.github.com/users/kevinkhill/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-10T14:14:03Z","updated_at":"2015-04-11T23:52:59Z","closed_at":null,"body":"I didn't see noted anywhere how to modify the headers on each api request. I also tried looking through the source, but coffee -> js is a bit cryptic to me.\r\n\r\nI want to be able to add a object such as:\r\n```\r\nheaders: {\r\n    'PRIVATE-TOKEN': 'not-a-real-private-token'\r\n}\r\n```\r\nthat will be added to each API request.\r\n\r\nI tried adding it after the base API url:\r\n```\r\nvar gitlabApi = slumber.API('http://my.gitlab.instance.com/api/v3/', {\r\n    request_opts: {\r\n      headers: {\r\n        'PRIVATE-TOKEN': 'not-a-real-private-token'\r\n      }\r\n    }\r\n  });\r\n```\r\nand I can see them added to the array when I ```console.log(gitlabApi.opts);```\r\n```\r\n{ request_opts: { headers: { 'PRIVATE-TOKEN': 'not-a-real-private-token' } },\r\n  base_url: 'http://my.gitlab.instance.com/api/v3/',\r\n  append_slash: true,\r\n  auth: null,\r\n  format: 'json',\r\n  serializer:\r\n   { default: 'json',\r\n     get_content_type: [Function],\r\n     dumps: [Function],\r\n     loads: [Function],\r\n     get_serializer: [Function],\r\n     serializers: { json: [Object] } } }\r\n```\r\nbut when the request is fired, I am still unauthorized and it doesn't seem like the headers are getting attached.\r\n\r\nWhen I use the plain request library, and pass the headers as such:\r\n```\r\nrequest({\r\n    uri: 'http://my.gitlab.instance.com/api/v3/users/keys',\r\n    method: 'get',\r\n    headers: {\r\n        'PRIVATE-TOKEN': 'not-a-real-private-token'\r\n    }\r\n})\r\n```\r\nit works, so I know that my key is good and the gitlab api is working.\r\n\r\nAny insight would be helpful, thank you!"},"comment":{"url":"https://api.github.com/repos/moul/node-slumber/issues/comments/91946980","html_url":"https://github.com/moul/node-slumber/issues/4#issuecomment-91946980","issue_url":"https://api.github.com/repos/moul/node-slumber/issues/4","id":91946980,"user":{"login":"moul","id":94029,"avatar_url":"https://avatars.githubusercontent.com/u/94029?v=3","gravatar_id":"","url":"https://api.github.com/users/moul","html_url":"https://github.com/moul","followers_url":"https://api.github.com/users/moul/followers","following_url":"https://api.github.com/users/moul/following{/other_user}","gists_url":"https://api.github.com/users/moul/gists{/gist_id}","starred_url":"https://api.github.com/users/moul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moul/subscriptions","organizations_url":"https://api.github.com/users/moul/orgs","repos_url":"https://api.github.com/users/moul/repos","events_url":"https://api.github.com/users/moul/events{/privacy}","received_events_url":"https://api.github.com/users/moul/received_events","type":"User","site_admin":false},"created_at":"2015-04-11T23:52:59Z","updated_at":"2015-04-11T23:52:59Z","body":"Hi @kevinkhill,\r\n\r\nI refactored a little bit the code so you can pass headers more easily, you can pass headers when creating the API object or when calling method.\r\n\r\nFor an example, checkout the tests here: https://github.com/moul/node-slumber/blob/master/tests/test.js#L423-L485"}}