EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
route.ts
Go to the documentation of this file.
1import { NextRequest, NextResponse } from "next/server";
2import { fieldpineServerApi } from "@/lib/server/fieldpineApi";
3import { getStoredAuth } from "@/lib/server/auth";
4
5export async function GET(request: NextRequest) {
6 try {
7 const authData = await getStoredAuth();
8 if (!authData) {
9 return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
10 }
11
12 const result = await fieldpineServerApi.buckApiCall({
13 "3": "retailmax.elink.discounts"
14 }, authData.apiKey!);
15
16 return NextResponse.json({
17 success: true,
18 data: result.DATS || [],
19 source: "elink",
20 });
21 } catch (error: any) {
22 console.error("Error fetching discounts:", error);
23 return NextResponse.json(
24 { success: false, error: error.message || "Failed to fetch discounts" },
25 { status: error.status || 500 }
26 );
27 }
28}