0
SyntaxError: Invalid or unexpected token line 5

I cant seem to find what is missing or where the syntax is wrong

const getData = () => {
    return new Promise((resolve) => {
        const connection = createConnection();
        const sqlQuery = fs.readFileSync('./file.sql').toString();
      ​
        connection.connect((err) => {
            if (err) {
                console.log('Error connecting to Db:' + err);
                return;
            }
            console.log('Database connection established.');
            connection.query(sqlQuery, (err, results, fields) => {
                if (err) throw err;
                connection.end((err) => {
                    if (err) {
                        console.log(err);
                    }
                    console.log('Database connection closed.');
                    resolve(results);
                });
            });
        });
    });
};
Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62

1 Answers1

0

Try deleting line 5 by backspacing it so that your new line 5 is now connection.connect((err) => { There is thing called an "invisible character" that can be created when copying and pasting code. Notice that when you hover over the syntax error in the dev tools on the browser it gives you \u200b. Here is another article discussion on stackoverflow that may be helpful:here