2
I have a system in Nodejs in development and finished a step, for the purpose of testing, I put it on a server and from that began to return me error in all lines of code in which I used the async functions.
Error:
async index(request, response){
SyntaxError: Unexpected identifier
...
Code:
const Authentication = require('./AdminAuthController');
module.exports = {
async index(request, response){ // esta é a linha do erro
const { admin } = request.headers;
const auth = await(Authentication.checkAuthentication(admin));
return response.json(auth);
}
My biggest problem is finding the reason to return this error, and in the tests I did on the localhost, all requests worked normally.
why doesn’t it
module.export =async index(request, response){
 const { admin } = request.headers;
 const auth = await(Authentication.checkAuthentication(admin));
 return response.json(auth);
}
, you are exporting an object and not a function.– Maury Developer
Below are other functions
– Victor Hugo
It’s probably a version problem. What version of Node.js do you use on your local computer and what version of the server Node?
– Luiz Felipe
I think this is the same problem. My computer is version > 10.1 and the server is 6.1
– Victor Hugo
https://medium.com/balta-io/nodejs-async-await-21ca3636252a. Victor please update to 8.0
– Maury Developer