How to structure your apps - to do app

Can’t seem to get the following tutorial to work. Here is a detailed explanation:

When I refresh the page i’m first of all getting a 404 not found when trying to fetch the todos. I have learned this error is coming from the controller function of read yet i don’t know why.
Furthermore when I add a todo two things happen: first i know that the todo is being added to the database because i can actually manually view it in Postbird and see that its been added however the response is a 400 bad request error.
The error actually causes the app to crash because it appears that the error being returned is an error object which cannot be used as a react child or something.
Therefore my problem is two-fold: first im trying to understand why my app just isnt properly returning the row(s) when creating/reading todos and therefore not displaying them and secondly how to actually implement the error properly so that it does not crash the app.

Thanks!

just a side note: when I posted this i said i couldnt get the solution code to work but now it appears to be working so maybe i accidentally edited something. still stuck with my own though and dont have a clue why!

After 2 hours stuck on this i realised the error. I didnt realise i had to return pool.query which i had on a second line and was being implicitly returned in the solution code. A stupid error but at least its fixed! Leaving this for anyone else who may have this misfortune.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.