#Official dashboard tutorial on nextjs, fetching from database not working.

5 messages · Page 1 of 1 (latest)

rough glen
#

I am doing the official tutorial path on nextjs site, https://nextjs.org/learn/dashboard-app/fetching-data I am on this page.
I added the fetchRevenue part to my page yet no data is shown, I even used some console.logs and database connection seems allright.
What could be the problem?
My page.tsx:
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 { fetchRevenue } from '@/app/lib/data';

export default async function Page() {
const revenue = await fetchRevenue();
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>
);
}

Learn about the different ways to fetch data in Next.js, and fetch data for your dashboard page using Server Components.

unreal swanBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

rough glen
#

Still can't find the solution, database is connected and data is fetched yet it just doesn't show anything.

rare blade
#

so when you console log revenue does it show the data?

rough glen
#

Yes, it does.