I'm trying to return a string value of an object generated by aws translate, the structure's object is
{
TranslatedText: "Hola",
SourceLanguageCode: "en",
TargetLanguageCode: "es"
}
the function
this.translate.translator.translateText(params, (err, data) => {
if (err) {
console.log(err, err.stack)
return err.stack;
}
if(data) {
console.log("translation :");
console.log(data.TranslatedText);
return data.TranslatedText;
}
});
I can see the string in console, but it is not returning it.
I think that I'm misunderstanding some async job here, and maybe the returned value is actually getting an undefined, but I'm not clear.