Need some help with await


Hi. I could use some help with await or the like. I have a simple script here:

And I’d like to be able to list the ‘lang’ with the translation, but since the calls are asynchronous I’m always getting the last language in the list. If you have a sec I could use some help. Thanks!


Hi, sorry for the late response. I’ve coded up an answer here:

To use await, you need to first convert the function to a promise-style function. Usually, this is as easy as doing require("util").promisify(translator). Unfortunately, this particular library did not use the standard callback-style for functions, so we had to do it manually on line 3. Let me know if you need any more help or explanation.




This is awesome! Thanks Francisco!