Does anyone have an example of what a callback should look like in Node.js for Syncano?
I've got an attempt within a CodeBox to retrieve my content within a class called "affirmations" but it doesn't seem to run my callback function. The console.log
of "Running"
appears, but no other console logs appear... and no errors either?
var Syncano = require('syncano');
var account = new Syncano({accountKey: 'MYKEY'});
console.log("Running");
account.instance('bold-rain-5584').class('affirmation').dataobject().list(function(err, res) {
console.log("Running affirmations");
if (err) {
console.log("Error!");
console.log(err); return;
}
console.log("Successful run.");
console.log(res);
});
Any ideas?
Your call back is accurate - this issue came down to an old version of the syncano
library which had a bug with callbacks. We are currently deploying a new version, and it should be fixed. It may be necessary to create a new Codebox to get the updated image (im not actually sure).
This version of the Syncano library still has promises available, so you would also be able to write this as the following:
account.instance('bold-rain-5584').class('affirmation').dataobject().list()
.then(function(res){
console.log("Successful run.");
console.log(res);
})
.catch(function(err) {
console.log("Error!");
console.log(err); return;
});