Having such a simple js DB app:
...
import mysql from 'mysql'
...    
server.get('/Authorize', async (reqObj: Request, resObj: Response) => {
    // check if the access token is already in the DB
    var connection = mysql.createConnection(db_connection);
    connection.connect(function(error) {
        if (error) {
            console.error('----> Authorize - MySql error connecting: ' + error.stack);
            return;
        }
        console.log('----> Authorize - Connected MySql as id ' + connection.threadId);
    });
    ...
    connection.end();
    console.log("----> Authorize - requesting the Discogs server for an request token...")
...
I'm getting the following output:
----> Authorize - requesting the Discogs server for an request token...
----> Authorize - Connected MySql as id ...
My question is WHY does the order of messages is swapped - why does the ...requesting the Discogs server for an request token... line is executed BEFORE the line ...Connected MySql as id. !?
