TypeError: con.connect is not a function when calling Client.connect()
See original GitHub issueimport dbConfig from '../dbConfig';
const { Client } = require('pg');
module.exports = {
query: async (text, params) => {
const client = new Client(dbConfig);
await client.connect();
const res = await client.query(text, params);
console.log(res)
}
};
DB Config is:
{
port: process.env.DB_PORT,
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
connectionTimeoutMillis:5000
}
Constantly prints TypeError: con.connect is not a function
I tried with several different databases, both local and hosted(I can connect to them through DBeaver) and all of the are giving me the same issue. Is it something wrong with my code?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
TypeError: con.connect is not a function con ... - Stack Overflow
Everytime I use con on the first file it works, but not on the second one, unless I repeat the whole mysql.createConnection. My...
Read more >TypeError: con.connect is not a function when calling Client ...
TypeError : con.connect is not a function when calling Client.connect()
Read more >Node.js with MySQL - w3resource
It provides all most all connection/query from MySQL. ... You can terminate a connection by calling the end() method :
Read more >db.query is not a function node js
pg_pconnect() opens a connection to a PostgreSQL database. It returns a connection resource that is needed by other PostgreSQL functions. If a second...
Read more >Node.js and MySQL Complete Tutorial - CodeForGeek
In this Node js and MySQL tutorial, we are going to learn how to connect Node ... sqlMessage: 'Client does not support authentication...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You do not even have
con.connect
anywhere in your code example, which suggests the error happens elsewhere.Warm compliments. I write a NodeJS app boilerplate. In case you are willing to further help, it is on repository https://github.com/web-needle/sappio