I tried connecting my Postgres Database to a Next.JS project and it didn't quite work out for me. I saw countless questions with my exact problem and none of them helped me.
Im getting this error
VercelPostgresError: VercelPostgresError - 'missing_connection_string': You did not supply a 'connectionString' and no 'POSTGRES_URL' env var was found.
First i made a next js project, uploaded it to github and connected vercel and installed verce
Set up the postgres database and run these commands
yarn global add vercel@latest
yarn add @vercel/postgres
vercel link
vercel env pull .env.development.local
And then created new file named data.ts in my app/lib folder
import { sql } from "@vercel/postgres";
export async function fetchCarData(carName: string) { const carDataPromise = sql`SELECT * FROM carinfo WHERE name=${carName};`;
const data = await Promise.all([carDataPromise]); return data;}I know i do not have to use Promise.all when i only have one promise but i plan on adding more.
Also tried running with either
npm run dev and vercel dev