Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promises not working? #11

Open
fdcastel opened this issue May 27, 2017 · 1 comment
Open

Promises not working? #11

fdcastel opened this issue May 27, 2017 · 1 comment

Comments

@fdcastel
Copy link

fdcastel commented May 27, 2017

This code (from promises sample)

import * as mysql from 'mysql2/promise';

let connection = mysql.createConnection(process.env['DB']);

connection.connect()
    .then(() => connection.query<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution'))
    .then(([rows, fields]) => {
        console.log('The solution is: ', rows[0]['solution']);
    });

Is causing he following error in runtime:

TypeError: connection.connect is not a function

Please, do notice the error occurs just in runtime. The TypeScript compiler doesn't shows any errors.

Using TypeScript version 2.3.2, Node.js version v6.10.3 and mysql2 version 1.2.0 (tried to downgrade to 1.1.1 but the problem remains).

@felixfbecker
Copy link
Contributor

Hmm, don't know why. Seems like it's not related to promises, but the connect function was removed? I don't remember where I copied this example from, maybe the library changed. Feel free to do a PR to correct this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants