keen / keen-analysis.js

A light JavaScript client for Keen
https://keen.io/docs/compute/
MIT License
40 stars 15 forks source link

Provide ability to set custom headers for caching purposes #10

Closed venil7 closed 8 years ago

venil7 commented 8 years ago

I'd like to be able to set custom headers on all outgoing requests, to provide my proxy to cache these requests

dustinlarimer commented 8 years ago

@venil7 great suggestion, I'd be more than happy to expose a headers method to the request chain that lets you set/get an object containing the header values to be used.

I imagine it would work like this:

client
  .post('YOUR_PROXY_URL')
  .headers({
    // define custom header values here
  })
  .send({
    event_collection: 'pageviews',
    timeframe: 'this_14_days'
  })
  .then(function(res){
    // do something with the result
  })
  .catch(function(err){
    // catch and handle errors
  });

How does that look?

venil7 commented 8 years ago

yes, that's exactly what I'm expecting, great!