21 lines
467 B
TypeScript
21 lines
467 B
TypeScript
// lib/helper/fetchVendors.ts
|
|
import { Vendor } from '@prisma/client'
|
|
|
|
export interface VendorWithAddress extends Vendor {
|
|
address: {
|
|
street: string
|
|
city: string
|
|
state: string
|
|
zip: number
|
|
}
|
|
}
|
|
|
|
export async function fetchVendorsClient(): Promise<VendorWithAddress[]> {
|
|
const res = await fetch('/api/vendors/fetch')
|
|
|
|
if (!res.ok) {
|
|
throw new Error('Failed to fetch vendors')
|
|
}
|
|
|
|
return res.json()
|
|
} |