Problems with Meteor 2.15 Async Migration

Hello,

i tried to migrate my meteor 2.15 server to async methods, using these guides: https://guide.meteor.com/prepare-meteor-3.0, https://dev.to/jankapunkt/prepare-your-meteorjs-project-for-the-big-30-release-14bf.

My main problem is that i can switch to async methods, like from collection.update(…) to collection.updateAsync(…) without problems, but any time i try to put await in front of the new async calls i get the error: Unexpected reserved word ‘await’.

Did i get something wrong? Thanks in advance for any kind of help.

You’ll need to make sure that the await is inside an async function, e.g.

async function something() {
 const result = await collection.updateAsync(…)
}

Thanks for the fast answer.
Finally it seems to works even on server startup with:

Meteor.startup(async () => {
  ...
  user = await Users.collection.findOneAsync({ ... });
  ...
});
2 Likes