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.
Still can’t use async/await? Disappointing
We can use async await now in FDK. Please verify your recommended node version and also update your fdk to the latest version and check. If this is still happening, please let us know here.
my node is old…v11.15.0. But node 7.6 started supporting async/await.
Oh. My node version is v12.13.1 and I am able to use it.
I know it should not make a difference, but upgrade your node maybe? Also what’s the error you are getting? Can you please quote that here.
Adding on to @yusrakhatri’s helpful comments, can you shed some light on the errors that you are getting? Is this observed in frontend code or backend?
It was when I ran fdk validate on the command line. It was like a ‘parsing error: unexpected token’ at the async function line.
Next time I get to that point, I’ll loop back with the exact error but it was something along those lines.
@jbwieg09 - You are right Jay.
When you build the app, there are two parts to it.
app/app.jsand related js will run in browser.
server/and related js will run in node environment.
We took steps to allow async await in the
We’ve built our app with all of the latest JS features, but due to limitations in FDK. We are unable to proceed further, will you please let us know the expected timeline to include the latest features in FDK so that we’ll be able to proceed further.
+1 on this.
If async/await is not supported - this should also be checked on
fdk run. I’ve just spent a good amount of time writing and testing an app, and now that I’m trying to build it, it’s finally told me I can’t use this.
Hi @Saif ,
I have installed both latest Node and fdk version still am getting that issue bot sure how can i resolve this issue. While doing fdk validate am getting - Parsing error: Unexpected token function on async key word place.
@Setmore_Support Could you create a new topic with your exact environment details (OS, Node version, and FDK version) and the code and related errors? We can help troubleshoot what is going wrong to throw this error.
It got resolved by updating the platform version and fdk version to 7 instead of 6. Migrated the app and now its working -
User ref links - About Platform version 2.2
Migrating existing apps from FDK 6 to FDK 7
Here the problem is when am running fdk -v right it showed me as am update to date already. but when seperately searched i found fdk 7 version is there and downloaded from out side got resolved the issue.