I tried to use an async function in my current project, but it seems FDK doesn’t support async/await - “fdk pack” returns an “Unexpected token function” error. I have no problem running the app locally. Using async function helps greatly with throttling requests and performing sequential operations, so can we expect support for this in the later versions of FDK?
Thanks for bringing it up! Currently, FDK validates the frontend code against
await functionality was introduced as a part of
ECMA2017. This results in an unfortunate
Unexpected token function error during
fdk pack or
fdk validate. At the moment, Babel can be used to convert the code to a compatible version. In the meantime, while we come up with a solution, I am moving this to our Feedback category.
Hey @Hem Thanks for your helpful reply. I’m also currently facing the same problem with the async/await functionality in my app and fdk pack isn’t working. It gives the same error as “Unexpected token function”. I thought ES5 or ES6 would support async/await functionality however I didn’t knew it’s from ECMA2017. Hope, To have a better solution for this problem since callback() method is a bit difficult and weird for me however, async/await is more easier and convenient for me. BTW, is there anyway, that I can change the ES version for my FDK pack? Because my app is working in my developer environment with fdk run, but it doesn’t works with the fdk pack. So maybe if I can change the ESLint or at least can make somehow my app published to my custom app it will be usable at least for my company. Thanks again.
Thanks for the feedback. We will consider bringing this support natively to the FDK since clearly async/await makes app code more readable and maintainable.
We don’t however currently have a way of modifying the ES version used by the FDK.