async and await Javascript operators are not recognised in the Javascript editor | XM Community
Question

async and await Javascript operators are not recognised in the Javascript editor

  • 1 December 2020
  • 2 replies
  • 71 views

Hi,
I will be using Javascript code in a Qualtrics question to run a Javascript game of Tetris. I have put this code in the Javascript editor however it appears that the Javascript operators async and await are not able to be recognised in the Qualtrics Javascript editor. It says "Invalid JavaScript! You cannot save until you fix all errors: Unexpected token function." However, when I remove async and await from the Javascript code there is no problem and the code is able to be saved so there appears to be something with async and await that isn't recognised by Qualtrics?
Could you please advise me on what to do? It would be really great if I could get this up and running as the async and await operators are essential for what I want to do with the code.
Thank you for your help!



2 replies

Userlevel 1
Badge

I encountered the same problem last week. If I am not mistaken, async functions are relatively new to Javascript, which might be the reason why they can't be implemented in Qualtrics yet. (I also found somewhere else that in the offline world, Node.js only supports async await in v7 and higher.)
Maybe there are compatibility issues with different browsers? I'm still quite new to JS, so I'm very curious.
Maybe someone with more background knowledge can shed some light on this?

Yes that's what I was thinking too. Looks like it could be a compatibility issue.

Would be great if someone with an understanding of this could let us know!

Leave a Reply