I try to wait for a function to return a value of my mysql table, and use this as a return for my const ProjektNameIntentHandler. This is my code:
const ProjektNameIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'ProjektNameIntent';
},
handle(handlerInput) {
let getProjektName = queryDb()
getProjektName.then(function(result) {
var projektName = result[0];
console.log(projektName.Test);
})
return handlerInput.responseBuilder
.speak(projektName.Test)
.withSimpleCard('Venture', projektName.Test)
.getResponse();
}
};
Now the problem is that get the result of ProjektNameIntentHandler
before projektName
got the result. First, I tried to put the second return into the scope of the function. But in this way, the result also belongs to the funtion and not as a return for my ProjektNameIntentHandler
.
So all I try do archieve is that the second return for the handlerinput
, waits for my getProjektName.then
to finish. How can I do that?