This is a difficult question for me to ask because I'm not truly sure what the issue is.
I have an Express JS server for routing and Node Postgres (PG) for the pool.
When I either go directly to localhost or use POSTMAN to test the routes there is no response except a simple loading screen. With POSTMAN, it gets stuck like so:
POSTMAN sending request...
Or for localhost it simply stays buffering/loading.
I am following this video on how to deploy a PERN app to Heroku. However, even after cloning the repo and updating all the packages within I cannot fetch data from my database (I am using PostgreSQL). I have updated all the database login information so it's not that.
Below is my code:
Server:
const express = require("express");
const app = express();
const cors = require("cors");
const pool = require("./db");
app.use(cors());
app.use(express.json());
app.get("/todos", async (req, res) => {
try {
const allTodos = await pool.query("SELECT * FROM todo");
} catch (err) {
console.error(err.message);
}
});
app.get("*", (req, res) => {
res.send("TEST");
});
app.listen(5000, () => {
console.log("server has started on port 5000");
});
Pool
const Pool = require("pg").Pool;
const pool = new Pool({
user: "postgres",
password: "postgres",
host: "localhost",
port: 5432,
database: "perntodo"
});
module.exports = pool;
All pool information is correct.
I have checked my database and there are active tables and data.
Again, there are no errors displayed so it's super hard for me to diagnose the problem.