Next.js Tutorial
Answered
West African Crocodile posted this in #help-forum
West African CrocodileOP
Hi, I'm currently trying to learn Next.js, and I'm following the tutorial (https://nextjs.org/learn/dashboard-app/fetching-data). I'm able to seed and query the database per chapter 6 (by going to the /seed and /query routes, as described). I then make it to this section in the attached image, and as soon as I add
import { fetchRevenue } from '@/app/lib/data'; followed by const revenue = fetchRevenue(), I get a 404 Not Found (also attached) instead of seeing the Revenue chart from that section. It complains about something in /.next/server/chunks/ssr, which is greyed out in VS Code and appears to be .gitignored. Code is as follows:import { Card } from '@/app/ui/dashboard/cards';
import RevenueChart from '@/app/ui/dashboard/revenue-chart';
import LatestInvoices from '@/app/ui/dashboard/latest-invoices';
import { lusitana } from '@/app/ui/fonts';
import { fetchLatestInvoices, fetchRevenue } from '@/app/lib/data';
export default async function Page() {
const revenue = await fetchRevenue();
// const latestInvoices = await fetchLatestInvoices();
return (
<main>
<h1 className={`${lusitana.className} mb-4 text-xl md:text-2xl`}>
Dashboard
</h1>
<div className='grid gap-6 sm:grid-cols-2 lg:grid-cols-4'>
{/* <Card title="Collected" value={totalPaidInvoices} type="collected" /> */}
{/* <Card title="Pending" value={totalPendingInvoices} type="pending" /> */}
{/* <Card title="Total Invoices" value={numberOfInvoices} type="invoices" /> */}
{/* <Card
title="Total Customers"
value={numberOfCustomers}
type="customers"
/> */}
</div>
<div className='mt-6 grid grid-cols-1 gap-6 md:grid-cols-4 lg:grid-cols-8'>
{/* <RevenueChart revenue={revenue} /> */}
{/* <LatestInvoices latestInvoices={latestInvoices} /> */}
</div>
</main>
);
}Answered by West African Crocodile
Found a solution thanks to this page https://vercel.com/docs/storage/vercel-postgres/sdk#sql. Was able to import
createClient and then const client = createClient();, then replace all sql calls with client.sql instead.2 Replies
West African CrocodileOP
Also, it looks like all the server components are throwing similar errors
West African CrocodileOP
Found a solution thanks to this page https://vercel.com/docs/storage/vercel-postgres/sdk#sql. Was able to import
createClient and then const client = createClient();, then replace all sql calls with client.sql instead.Answer