vercel / next-learn

Learn Next.js Starter Code
https://next-learn-dashboard.vercel.sh/
MIT License
3.63k stars 1.87k forks source link

Chapter 6: Setting up your database - Error [object Object] #833

Open pyMasta opened 1 month ago

pyMasta commented 1 month ago

Hi, I am on my second round of doing this next.js tutorial from scratch in an attempt to seed the postgres database correctly, but I just cannot figure out why I am non de-script errors (Error: [object Object]), even when on my first try I tried to log everything on my first go around. Please help!

I am pasting a screenshot of my browser errors and linking my current repo if anyone is willing to take a look. I read many other posts on chapter 6 errors, correctly commented out my route.ts ("uncomment this file..."), compared with a friend who got it working (but, looks like his route.ts file was different from a few months ago), see no logs anywhere in Vercel, etc. I confirm I correctly pasted over the env variables into my .env file. I got an error trying to install bcryptjs to see if that was somehow the error that Vercel recommends to check. Let me know if there is anything I can try, I am very confused.

Screenshot 2024-08-14 at 9 33 17 AM

Repo: https://github.com/pyMasta/nextjs-v3

pyMasta commented 1 month ago

Well, it looks like somebody else had the same error that i miss, and it works if you run /seed on your deployed environment, not local like the instructions have: https://github.com/vercel/next-learn/issues/792

However, I am not sure if this is the way Vercel does want you to do this or if they just have not updated the tutorial.

SiyabongaMat commented 1 month ago

I get the exact same error. This is my fourth rerun of the project tutorial 😓

pyMasta commented 1 month ago

I hear you. I just got it working, saw the data, and now Vercel errors saying "Failed to fetch tables in your database" and the data is gone :/

SiyabongaMat commented 1 month ago

Does the error say: 'error fetching card data' and shows that the error is in the fetchInvoices method?

SiyabongaMat commented 1 month ago

I figured something out. It worked finally. What I did: I changed the region of the postgres database to frankfurt germany. It is more in line with my timezone. Also, there is a step that I missed. Its so small its easy to miss it. Just after telling you to create a postgres database and connecting it to you project it subtly tells you to install the vercel/postgres sdk with this line:

Finally, run pnpm i @vercel/postgres in your terminal to install the Vercel Postgres SDK

In my other attempts, when I checked my package.json file for dependancies, I always thought there was no need to install the vercel/postgres sdk because I thought it was already installed, but turns out you need to install the sdk.

Hope this helps 😁👍

akkshayTandon commented 3 weeks ago

@SiyabongaMat Hey, glad to hear that you resolved issue on your own. I think it should be removed.

KinonoChen commented 2 weeks ago

I figured something out. It worked finally. What I did: I changed the region of the postgres database to frankfurt germany. It is more in line with my timezone. Also, there is a step that I missed. Its so small its easy to miss it. Just after telling you to create a postgres database and connecting it to you project it subtly tells you to install the vercel/postgres sdk with this line:

Finally, run pnpm i @vercel/postgres in your terminal to install the Vercel Postgres SDK

In my other attempts, when I checked my package.json file for dependancies, I always thought there was no need to install the vercel/postgres sdk because I thought it was already installed, but turns out you need to install the sdk.

Hope this helps 😁👍

Hi, I was wondering if you ended up successfully seeding locally?I'm having this problem: I can successfully seed an application that I deployed on vercel, but it keeps failing to seed locally, maybe vercel doesn't support local connections to vercel/postgres?