diff --git a/backend/db.js b/backend/db.js index fbc294c..a68fec2 100644 --- a/backend/db.js +++ b/backend/db.js @@ -11,9 +11,17 @@ const db = new Client({ // create connection to database db.connect() - .then(() => console.log('Successfully connected to database')) - .catch((err) => console.log('Error on connecting to database: ', err)); - + .then(() => { + console.log('Successfully connected to database'); + // if connection is succesful create tables + createTables() + .catch((err) => { + console.error('Error creating tables:', err); + }); + }) + .catch((err) => { + console.error('Error connecting to database: ', err); + }) async function createTables() { try { // Create accounts table