fehler api
This commit is contained in:
parent
2dec18fc97
commit
af1c0456d7
|
|
@ -21,7 +21,10 @@ export async function POST(request: Request) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const lead = await (db as any).lead.create({
|
// Use typed db client - keeping (db as any) temporarily if types are missing locally,
|
||||||
|
// but cleaner code should use db.lead directly.
|
||||||
|
// We will trust the user to run `npm run build` which runs `prisma generate`.
|
||||||
|
const lead = await db.lead.create({
|
||||||
data: {
|
data: {
|
||||||
email: email.toLowerCase().trim(),
|
email: email.toLowerCase().trim(),
|
||||||
source: source || 'reprint-calculator',
|
source: source || 'reprint-calculator',
|
||||||
|
|
@ -34,8 +37,12 @@ export async function POST(request: Request) {
|
||||||
return NextResponse.json({ success: true, id: lead.id });
|
return NextResponse.json({ success: true, id: lead.id });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error saving lead:', error);
|
console.error('Error saving lead:', error);
|
||||||
|
// Return the actual error message for debugging purposes
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: 'Failed to save lead' },
|
{
|
||||||
|
error: 'Failed to save lead',
|
||||||
|
details: error instanceof Error ? error.message : String(error)
|
||||||
|
},
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +51,7 @@ export async function POST(request: Request) {
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
const [leads, total] = await Promise.all([
|
const [leads, total] = await Promise.all([
|
||||||
(db as any).lead.findMany({
|
db.lead.findMany({
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
take: 10,
|
take: 10,
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue