Need your help, can't figure out what's wrong with my code. Your help is much appreciated.
Firstly, I have a main index.js file where all my main code is and I want it to call another function from another file which is post.js and execute whatever I put in that file but I can't make it work. I have an error called undefined.
index.js (Main File)
var xxx = require('./post.js');
function handlepostWaterRequest(intent, session, callback) {
var cardTitle = "Water"
var speechOutput = "Ok!, Now watering plants!" + xxx.post;
callback(session.attributes,
buildSpeechletResponse(cardTitle, speechOutput, "", true));
}
post.js (Second File)
var ubidots = require('ubidots');
var client = ubidots.createClient('***API Key***');
module.exports = {
post: client.auth(function () {
var pumpData = this.getVariable('***Key***');
pumpData.getValues(function (err, data) {
console.log("Uploading..............");
pumpData.saveValue(0);
});
})
};
How do I call the xxx.post
properly and make it executable?
Much thansks!