Reputation: 31
So, I'm trying to make a bot in Bot Framework that will retrieve information from an API and let the user to pick from that information. The problem is that I tried a lot of methods of get that information and none worked.
This is my code without async or await
function(session){
servicesJSON = get.getServices(par, (res) => {});
for (var k= 0;k<Object.keys(servicess).length; k++){
services[k] = servicesComplete[k].name;
}
builder.Prompts.choice(builder, session, 'Which service do you want?', services); //this has to be sync
},
Then I tried to wrap the waterfall function from Bot Framework in an async function and "await" for servicesJSON
async function(session){
servicesJSON = await get.getServices(par , (res) => {});
for (var k= 0;k<Object.keys(servicess).length-2; k++){
services[k] = servicesComplete[k].name;
}
builder.Prompts.choice(builder, session, 'Which service do you want?', services); //this has to be sync
},
But that didn't work either.
Upvotes: 0
Views: 97
Reputation: 1642
In your callback you aren't returning anything, have you tried this:
servicesJSON = await get.getServices(par , (res) => res);
Upvotes: 1