when I run deploy my app to heroku I got this error
2022-05-26T01:38:34.587567+00:00 app[web.1]: TypeError: str.charAt is not a function
2022-05-26T01:38:34.587577+00:00 app[web.1]: at parse (/app/node_modules/pg-connection-string/index.js:13:11)
2022-05-26T01:38:34.587577+00:00 app[web.1]: at new ConnectionParameters (/app/node_modules/pg/lib/connection-parameters.js:56:42)
2022-05-26T01:38:34.587578+00:00 app[web.1]: at new Client (/app/node_modules/pg/lib/client.js:19:33)
2022-05-26T01:38:34.587579+00:00 app[web.1]: at BoundPool.newClient (/app/node_modules/pg-pool/index.js:213:20)
2022-05-26T01:38:34.587579+00:00 app[web.1]: at BoundPool.connect (/app/node_modules/pg-pool/index.js:207:10)
2022-05-26T01:38:34.587579+00:00 app[web.1]: at BoundPool.query (/app/node_modules/pg-pool/index.js:389:10)
2022-05-26T01:38:34.587580+00:00 app[web.1]: at Object.exports.getUserByEmail (/app/server/db/postgresql/queries.js:57:6)
2022-05-26T01:38:34.587580+00:00 app[web.1]: at /app/server/routes/api/user.js:32:38
2022-05-26T01:38:34.587580+00:00 app[web.1]: at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2022-05-26T01:38:34.587581+00:00 app[web.1]: at next (/app/node_modules/express/lib/router/route.js:144:13)
although it is works fine on my localhost and heroku local.
exports.getUserByEmail = async (email) => {
let user = "";
await pool
.query("SELECT email FROM users WHERE email = $1", [email])
.then((res) => {
if (res.rows[0]) {
user = res.rows[0].email;
}
})
.catch((e) => {
throw e;
});
return user;
};
user.js
try {
let payload = {};
const user = await poolQuery.getUserByEmail(email);
if (user) {
return res
.status(400)
.json({ errors: [{ msg: "User already exists" }] });
} else {
const salt = await bcrypt.genSalt(10);
const encryptedPassword = await bcrypt.hash(password, salt);
Thank you a lot for your help.