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 { cwaPosApi } from '@/lib/cwa-pos-api';
3
4export async function GET(request: NextRequest) {
5 // Try to get API key from cookies or headers
6 const apiKey = request.cookies.get('FieldpineApiKey')?.value ||
7 request.headers.get('Authorization')?.replace('Bearer ', '');
8
9 if (apiKey) {
10 cwaPosApi.setApiKey(apiKey);
11 }
12
13 try {
14 const result = await cwaPosApi.getRetailConfig();
15
16 if (result.error) {
17 return NextResponse.json(
18 { error: result.error },
19 { status: 500 }
20 );
21 }
22
23 return NextResponse.json(result);
24 } catch (error) {
25 console.error('POS API Error:', error);
26 return NextResponse.json(
27 { error: 'Internal server error' },
28 { status: 500 }
29 );
30 }
31}