Skip to content
Advertisement

SyntaxError when using try/catch with aync/await in NodeJS [closed]

I am a beginner in Node Js. I am not able to figure out why the below code gives syntax error with catch().I have upgraded the Node JS V14. Any help will be appreciated here

JavaScript

Error:

JavaScript

Advertisement

Answer

catch doesn’t expect a function, it’s just a special syntax to detect the error:

JavaScript
Advertisement