Skip to content

Commit 5e44aee

Browse files
fix(pos-app): handle empty response body in transactions proxy
The upstream API can return an empty body on error responses, causing JSON.parse to fail. Read as text first and only parse if non-empty. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49e7bab commit 5e44aee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dapps/pos-app/api/transactions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
6161
headers: getApiHeaders(credentials.apiKey, credentials.merchantId),
6262
});
6363

64-
const data = await response.json();
64+
const text = await response.text();
65+
const data = text ? JSON.parse(text) : {};
6566

6667
if (!response.ok) {
6768
return res.status(response.status).json(data);

0 commit comments

Comments
 (0)