Reputation: 1475
I have a couple of basic local json files. I want to visualize the json data using keen.io. But somehow I cannot send my events to keen. There are no errors in the console.
var client = new Keen({
projectId: "key",
writeKey: "key"
});
var data = $.getJSON( "data/web_stories.json", function( data ) {
var storyData = data
Keen.ready(function(){
var multipleEvents = {
"stories": data
};
// Send multiple events to several collections
client.addEvents(multipleEvents, function(err, res){
if (err) {
console.log('there is an error!')
}
else {
console.log('data sent')
}
The data looks like this
[
{ link: "www.link.com",
heading: 'here is the heading',
image: "www.image.com" },
{ link: "www.link.com",
heading: 'here is the heading',
image: "www.image.com" }
]
Upvotes: 0
Views: 128
Reputation: 607
I'm seeing data
defined a few times. How about this:
var client = new Keen({
projectId: "key",
writeKey: "key"
});
Keen.ready(function(){
$.getJSON( "data/web_stories.json", function( data ) {
// Send multiple events to several collections
client.addEvents({ 'stories': data }, function(err, res){
if (err) {
console.log('there is an error!')
}
else {
console.log('data sent')
}
});
});
});
Upvotes: 1
Reputation: 10176
you have some syntax errors, try this:
var client = new Keen({
projectId: "key",
writeKey: "key"
});
var multipleEvents;
var data = $.getJSON( "data/web_stories.json", function( data ) {
var storyData = data
Keen.ready(function(){
multipleEvents = {
"stories": data
};
});
};
// Send multiple events to several collections
client.addEvents(multipleEvents, function(err, res){
if (err) {
console.log('there is an error!')
}
else {
console.log('data sent')
}
}
Upvotes: 0