I am having some difficulties with node.js & using functions. My problem is when I call a function, node.js doesnt wait for it to finish and I ended up getting nothing as my return values. This is what I have
exports.handle = (event, context,callback) => {
switch (event.request.type)
{
case "IntentRequest":
console.log('INTENT REQUEST')
switch(event.request.intent.name)
{
case "MoveDown":
readpos()
}
}}
function readpos(){
var position = []
//this code parses an array and gets me x y values
return position }
My problem is I end up getting an empty array because node.js runs to fast. Im assuming I have to do something with callback but im unsure on how to implement callback. I've tried reading online tutorials on callback but all of them have confused me as well and I cant seem to apply what online resources say to my cold. My main language is c++ & Python.