[Solved] Use await in blaze template event

hi,

I see we can use await in the onRendered, onCreated, helpers but I would like to do something after a button is clicked. (i want to get some data from third party site), how can I do this? thanks!

Template.questions.events({
    'submit' (event) {
        event.preventDefault();
    ...
            var select = await nav.makeSelectionInField("Level 2", selectValues);

the error I get is While building for web.browser: imports/ui/insert/questions.js:48:25: imports\ui\insert\questions.js: await is a reserved word (48:25)

somehow this is also not mentoined in @robfallows excellent post

Try:

Template.questions.events({
    async 'submit' (event) {
        event.preventDefault();
    ...
            var select = await nav.makeSelectionInField("Level 2", selectValues);
1 Like

thanks a lot! that solved the issue, I only tried submit async:slight_smile:

1 Like