Open davisc91 opened 4 years ago
Hi Catherine, you are the unlucky first student to complete this project using the new pg
version 8.0!
In this version of pg
the way to connect to a database securely has changed. The solution is to replace this:
ssl: true
With this:
ssl: { rejectUnauthorized: false }
Thanks for sharing the error message in your console. That was really helpful in troubleshooting this and I'm sorry I didn't catch this difference before you had to bump into it!
I've updated the lesson to include both the quotes around the database URL in package.json
and the new syntax for connecting to a pg
database securely. π
I changed that line and now the /get todos works, but /get todos:id still doesn't seem to work.
Also, when I pushed this to heroku, it published at https://peaceful-bayou-91373.herokuapp.com/ instead of the project name. I remember when I did heroku create
at the start of the project it gave me that name automatically, but I didn't know if it would matter or not.
It's okay, I can use a different URL, thanks for sharing it with me. π
It looks like this error is appearing when I access GET /todos/:id
in your API:
error: relation "todo" does not exist
Looking at the SQL in this method, it looks like it is selecting from the table todo
instead of todos
like your GET /todos
method does. I suspect that if you update the table name, things will work as expected. You may want to double-check the other SQL queries in your API as well.
Changed it!
Nice, this project is so good, Catherine! All the methods are there and they work great. And I really like the error-handling. Outstanding work! π
Thanks for reaching out to work through the issues on this project, it's really fantastic! π :shipit:
Update your todo list API to use a relational database
@egillespie Can you take a look at this? It's hosted here and meets the following criteria:
todo
table in the databasetodo
table is saved in the projectpg
client is used to create a connection pool and access the databaseI've put all the code in server.js. However, it doesn't seem to ever connect to the database. In the terminal, when I run
yarn server
and try to do any of the routes, the terminal gives me these errors:(node:2802) UnhandledPromiseRejectionWarning: Error: self signed certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1321:34) at TLSSocket.emit (events.js:210:5) at TLSSocket._finishInit (_tls_wrap.js:794:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:608:12) (node:2802) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:2802) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I do not know where to go from here. Thank you so much for your help. Edit: When I pushed this to heroku, it published at https://peaceful-bayou-91373.herokuapp.com/ instead of the project name... I remember when I did
heroku create
at the start of the project it gave me that name, but I didn't know if it would matter or not. Could this be why it's not connecting?