Trouble with Expense Tracker (MVC Architecture for Full-Stack App)

Hi,

I really cant get this app up and running. Ive search around, tried every npm package the can be related to this, so im a little stuck… The app runs in the terminal, but in devtools I get a lot of errors. Also, tried to delete repo, running npm i again and every other external package that helps building the UI.

What am I missing?

You are not missing anything. I’m at the same part of the course as you and the starter-code is broken. They need to update their courses so the code works.

1 Like

I am in about the same situation. I have gone through the tutorial, I looked online to sort all the ongoing error I received and, when I finally finished with no errors in the Terminals, the page wasn’t doing much… :sweat_smile:
I thought I have done some wrong (even though the code I had to write is at the minimum … but this is a different story) so I have copied the .env over, ran the npm i and start the servers. Here is the result:

1 Like

Try to add missing “await” in view folder App.js when returning Modal
res suppose to look like this:
const res = await fetchExpenses(selectDate.getTime());
setExpenses(res)
Everything worked for me after I added missing await

2 Likes

PERFECT
THANK YOU FOR THIS !!
all good now !!woop!

I’m getting this error,I’m not sure if it’s related to postgresql database configuration:

undefined is not a function (near ‘…expenses.map…’)

I appreciate any assistance you can offer.

I have the same problem : expense.map is not a function ( in console dev tools : ExpenseList.js). In App.js : await fetchExpenses in Modal is available.
What is the solution?

I get the same expense.map error. Even the solution code gives the same error unfortunately. Appears to not have been tested before adding it to the curriculum. Shame they haven’t fixed it after all this time.

1 Like

I figured out how to fix this.

From past mistakes, I’ve learned that when js screams about .map not being a function, its because the variable that you’d save the array to is undefined, so there’s nothing to .map over.

This could be due to one of two problems:

  1. You’re not connecting to your datastore properly and the error is being suppressed for one reason or another.
  2. Your datastore doesn’t contain any data.

After investigating, there’s an issue in the instructions with the initial Postgres setup.

First, you need to ensure that your postgres server HAS A PASSWORD SET or remove the DB_PASSWORD line

DB_USER=REDACTED
DB_PASSWORD=REDACTED
DB_HOST=localhost
DB_POST=5432
DB_DATABASE=expenses
PORT=8000

Second, you need to ensure that you’ve created a DB called expenses in your postgres server BEFORE you run the CREATE TABLE command in the instructions. Put more simply, the expenses table needs to live in the expenses db, because PG pools are looking for a specific DB called expenses to query.

You may also need to add at least one row to that table. I’m not sure if this is necessary, as I’d already added a row before I realized the issue might have been with setup. Anyway, it stops the .map error and the app works as designed. Hope this is helpful!