3

The following docs make it seem like my code should work, however I'm getting an undefined error, I'm sure it's something simple but I can't quite get my head around it.

https://github.com/keen/keen-js/blob/master/docs/visualization.md#automatic-updates

var clicks_keen = new Keen.Query("count", {
eventCollection: "clicks",
groupBy: "campaign.id",
interval: window.interval,
timeframe: window.timeframe
});

clicks_keen.refresh();
Jake232
  • 227
  • 1
  • 5
  • 11
  • Where are `window.interval` and `window.timeframe` defined? Are you using globals on purpose? – Juho Vepsäläinen Nov 08 '14 at 19:25
  • They are defined further up. There is no real reason I'm using globals, the code just needs cleaning up. However even without those variables and just using standard strings the problem persists. The refresh() call seems to be the problem, however their docs make it seem like this should work. – Jake232 Nov 08 '14 at 19:30
  • 3
    Based on their docs if you do something like `var req = client.run ...` first, you get handle to a thinger you can do `req.refresh()` with. I think that's your problem. – Juho Vepsäläinen Nov 08 '14 at 19:35

1 Answers1

4

It turns out that bebraw was correct. You need to store the result of client.run() in a variable, and call refresh on that object.

You also need to keep the original Query in a variable though as to update any actual data for the query (change the timeframe etc) you need that object.

Jake232
  • 227
  • 1
  • 5
  • 11