Files
cbd420/app/api/buyers/route.ts
2025-12-20 22:05:21 +01:00

20 lines
522 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import pool from '@/lib/db'
// GET /api/buyers - Get all buyers
export async function GET(request: NextRequest) {
try {
const [rows] = await pool.execute(
'SELECT id, username, email, created_at FROM buyers ORDER BY created_at DESC'
)
return NextResponse.json(rows)
} catch (error) {
console.error('Error fetching buyers:', error)
return NextResponse.json(
{ error: 'Failed to fetch buyers' },
{ status: 500 }
)
}
}