⨯ SyntaxError: await is only valid in async functions and the top level bodies of modules #213
Unanswered
tuhanglsWorld
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
⨯ SyntaxError: await is only valid in async functions and the top level bodies of modules
`export const emailRegister = action
.schema(RegisterSchema)
.action(async ({ parsedInput: { email, password, name } }) => {
await new Promise((res) => setTimeout(res, 1000));
console.log(email, password, name);
const hashedPassword = await bcrypt.hash(password, 10);
console.log(hashedPassword);
});`
This problem occurs when using the mysql db operation in an asynchronous action function
Beta Was this translation helpful? Give feedback.
All reactions