Parse-server: Can't usage await in job.

Created on 19 Apr 2020  路  3Comments  路  Source: parse-community/parse-server

/parse-server/cloud/main.js:353
const player = await new Parse.Query("Player").equalTo('name','test').find({
^^^^^

SyntaxError: await is only valid in async function
at wrapSafe (internal/modules/cjs/loader.js:1072:16)
at Module._compile (internal/modules/cjs/loader.js:1122:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at new ParseServer (/parse-server/lib/ParseServer.js:140:9)
at Function.start (/parse-server/lib/ParseServer.js:332:25)
at start (/parse-server/lib/cli/parse-server.js:90:22)
Configuration loaded from /etc/parse/xxx.json

Most helpful comment

@lorki How's your job defined? To use the await keyword, your function must be prepended with the async keyword. E.g.

Parse.Cloud.job("cloud:job:foo", async (request) => {
  const player = await new Parse.Query("Player").equalTo('name','test').find({...
});

All 3 comments

@lorki How's your job defined? To use the await keyword, your function must be prepended with the async keyword. E.g.

Parse.Cloud.job("cloud:job:foo", async (request) => {
  const player = await new Parse.Query("Player").equalTo('name','test').find({...
});

@thecynicalpaul wow锛宼hink you.it's working.

Hi @lorki, I'm glad this is resolved 馃槃

In future please post questions like this over on our community forum.

We try to keep GitHub issues reserved for bug reports & feature requests - see the section on help and communication on our website.

Was this page helpful?
0 / 5 - 0 ratings