Reputation: 33
I have syntax error(unexpected token ".") in line config.db.database;
.
This is my code in file
const config = require('../config/config')
const db = {}
const sequelize = new Sequelize({ // SQL constructor
config.db.database;
config.db.user;
config.db.password;
config.db.option;
});
And this is my required config.js code:
module.export = {
port: process.env.PORT || 3011,
db: {
database: process.env.DB_NAME || 'tabtracker',
user: process.env.DB_USER || 'tabtracker',
password: process.env.DB_PASSWORD || 'tabtracker',
options: {
dialect: process.env.DIALECT || 'sqlite',
host: process.env.HOST || 'localhost',
storage: './tabtracker.sqllite'
}
}
}
Pls help, really dont know how to fix it, I think doing everything right, cuz Im copying a tutorial code.
Upvotes: 0
Views: 1633
Reputation: 1074355
There are two fundamental errors in that code:
You're using a ;
to separate properties in an object initializer; it should be ,
, not ;
You're specifying properties using the new(ish) shorthand syntax, but you can only do that with a simple identifier, not a property access expression such as config.db.option
. When you have an expression, you need to supply the property name explicitly.
You may have wanted:
const sequelize = new Sequelize({ // SQL constructor
database: config.db.database,
user: config.db.user,
password: config.db.password,
option: config.db.option
});
...but you'll need to double-check the property names (on the left before the :
).
Upvotes: 1