I am getting the following error in async usage on ESLINT.
eslint Parsing error: Unexpected token function with async
Here is my
It's an error regarding func-style
. By default it uses type expression
, and the correct way to represent functions using this as expression
is:
const get = async get(req, res) {
const user = await service.get();
console.log("From db",user.username);
res.send('ok');
};
Check the docs for further examples, https://eslint.org/docs/rules/func-style
UPDATE: Forgot to see you have added error, what you were doing was right,
const get = async function get(req, res) {
const user = await service.get();
console.log("From db",user.username);
res.send('ok');
};
Just remove func-style
from eslint.