mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-11 09:51:47 +00:00
chapter 8
This commit is contained in:
@@ -9,12 +9,11 @@ import {
|
||||
Revenue,
|
||||
} from './definitions';
|
||||
import { formatCurrency } from './utils';
|
||||
import { unstable_noStore as noStore } from 'next/cache';
|
||||
|
||||
export async function fetchRevenue() {
|
||||
// Add noStore() here prevent the response from being cached.
|
||||
// This is equivalent to in fetch(..., {cache: 'no-store'}).
|
||||
noStore();
|
||||
|
||||
try {
|
||||
// Artificially delay a reponse for demo purposes.
|
||||
// Don't do this in real life :)
|
||||
@@ -34,7 +33,6 @@ export async function fetchRevenue() {
|
||||
}
|
||||
|
||||
export async function fetchLatestInvoices() {
|
||||
noStore();
|
||||
try {
|
||||
const data = await sql<LatestInvoiceRaw>`
|
||||
SELECT invoices.amount, customers.name, customers.image_url, customers.email, invoices.id
|
||||
@@ -55,7 +53,6 @@ export async function fetchLatestInvoices() {
|
||||
}
|
||||
|
||||
export async function fetchCardData() {
|
||||
noStore();
|
||||
try {
|
||||
// You can probably combine these into a single SQL query
|
||||
// However, we are intentionally splitting them to demonstrate
|
||||
@@ -95,7 +92,6 @@ export async function fetchFilteredInvoices(
|
||||
query: string,
|
||||
currentPage: number,
|
||||
) {
|
||||
noStore();
|
||||
const offset = (currentPage - 1) * ITEMS_PER_PAGE;
|
||||
|
||||
try {
|
||||
@@ -128,7 +124,6 @@ export async function fetchFilteredInvoices(
|
||||
}
|
||||
|
||||
export async function fetchInvoicesPages(query: string) {
|
||||
noStore();
|
||||
try {
|
||||
const count = await sql`SELECT COUNT(*)
|
||||
FROM invoices
|
||||
@@ -193,7 +188,6 @@ export async function fetchCustomers() {
|
||||
}
|
||||
|
||||
export async function fetchFilteredCustomers(query: string) {
|
||||
noStore();
|
||||
try {
|
||||
const data = await sql<CustomersTable>`
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user