momi-foundation-coding/nodejs-api-cli

Fix issue when running npm run start

Closed this issue · 0 comments

Just fix the error

Had trouble starting the app that is created but this change should work to fix #107.

Here is the error I am met with when running npm run start inside the created directory:

> babel-node src/index.js

/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/core/lib/parser/index.js:95
    throw err;
    ^

SyntaxError: /Users/****/Documents/nodejs-api-cli/example/src/controllers/user.js: Can not use keyword 'await' outside an async function (30:4)

  28 | }
  29 | export const signupUserController = (req, res) => {
> 30 |     await query(createUserQuery, async (err, result) => {
     |     ^
  31 |         if (err) {
  32 |             return responseHandler(res, err, 500);
  33 |         }
    at Parser._raise (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/error.js:60:45)
    at Parser.raiseWithData (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/error.js:55:17)
    at Parser.raise (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/error.js:39:17)
    at Parser.checkReservedWord (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:2415:14)
    at Parser.parseIdentifierName (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:2362:12)
    at Parser.parseIdentifier (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:2320:23)
    at Parser.parseExprAtom (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:997:25)
    at Parser.parseExprSubscripts (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:563:23)
    at Parser.parseUpdate (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:543:21)
    at Parser.parseMaybeUnary (/Users/****/Documents/nodejs-api-cli/example/node_modules/@babel/parser/src/parser/expression.js:527:17) {
  loc: Position { line: 30, column: 4 },
  pos: 850,
  code: 'BABEL_PARSE_ERROR'
}``