Hey
i am trying to use async in dailogflow to call an google translate API but i got this error that async function is only available in ES8 and i checked if there is solution in internet but i did not find.
this is the code i wrote:
async function detectLanguage(agent , text , target) {
const translate = new Translate();
let [translations] = await translate.translate(text, target);
//translations = Array.isArray(translations) ? translations : [translations];
agent.add('Translations:');
translations.forEach((translation, i) => {
agent.add(`${text[i]} => (${target}) ${translation}`);
});
}
and :
function test(agent) {
const text = 'hej';
const target = 'en';
return detectLanguage(agent, text, target).then(result => {
agent.add('${result}');
});
}
please anyone can help me