I'm following a tutorial and I can't undestand this error, since I've double checked, pretty sure is my newbieness attacking again...
SyntaxError: Unexpected token {
at new Script (vm.js:51:7)
at createScript (vm.js:138:10)
at Object.runInThisContext (vm.js:199:10)
at Module._compile (module.js:624:28)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
[nodemon] app crashed - waiting for file changes before starting.
..
module.exports = function() {
this.getNoticias(connection, callback){
connection.query('SELECT * FROM noticias', callback);
}
return this;
}
The expression you used to declare a function is invalid.
In order to declare a function, you should use this.getNoticias = function(...)
So the complete code should look like this:
this.getNoticias = function(connection, callback){
connection.query('select * from noticias', callback);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.