Async function stopped working (inside form onSubmit)
Unanswered
Bigeye scad posted this in #help-forum
Bigeye scadOP
I have a simple login form using nextjs and react-hook-form. In the on submit function, I call a server action. It has been working perfectly, but all of a sudden I get this error when trying to submit
I dont understand why I am getting this error all of a sudden. Here is the code
All my other server actions being called from the client are also not working?
Nextjs 14.2.5
Uncaught (in promise) SyntaxError: await is only valid in async functions and the top level bodies of modulesI dont understand why I am getting this error all of a sudden. Here is the code
All my other server actions being called from the client are also not working?
Nextjs 14.2.5
2 Replies
Bigeye scadOP
I have another project where this code works absolutely fine....
Sun bear
this should work lol. maybe try using the function syntax:
also the
https://react-hook-form.com/ts
async function onSubmit(values) {
const result = await login(values)
// ... code
}also the
react-hook-form docs do it a little different so maybe try that:https://react-hook-form.com/ts