question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'query' of undefined

See original GitHub issue

I am sorry to be the first that is starting an open issue. My implementation returns Cannot read property ‘query’ of undefined error

var con;
mysql.createConnection({
    host: config.db.host,
    user: config.db.username,
    password: config.db.password,
    database: config.db.database
}).then(function(connection){
    con = connection;
});

con.query(queries.allUsers).then(function (err, users) {
    console.log(users);
});

What could I have done better?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
christiannwambacommented, Sep 11, 2015

@lukeb-uk Ok. We call it a day then…

1reaction
CodeFoodPixelscommented, Sep 11, 2015

The doc examples aren’t wrong, but they probably aren’t the best for those unfamiliar with promises. I’ll have a look at clarifying them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

i am getting cannot read property 'query' of undefined
It seems there is error in your mysql connection.try make proper connection first. Step 1: Create the pool (only do this once) var...
Read more >
Node JS TypeError: Cannot read property 'query' of undefined
I will provide a simple example of finding an error cannot read property 'query' of undefined. In this example use CRUD in the...
Read more >
i get error like ' Cannot read property 'query' of undefined', it ...
i get error like ' Cannot read property 'query' of undefined', it doesn't know query method when retrieving data from db. Like
Read more >
cannot read properties of undefined (reading 'query') - You.com
The "Cannot read properties of undefined" error occurs for multiple reasons: Accessing a property on a variable that stores an undefined value. Accessing...
Read more >
TypeError: Cannot read property 'query' of undefined ... - GitHub
It really depends on what your code in the /node_www/crawler.x-sells.com/autoInit.js file is.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found