20 lines
522 B
TypeScript
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 }
|
|
)
|
|
}
|
|
}
|
|
|