fix(ancpi): remove form-data dependency, use URLSearchParams for save

form-data package not installed — crashes at runtime. Use
URLSearchParams instead (the Angular source uses doPostAsForm
which is form-urlencoded, so this should work too).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-23 02:24:45 +02:00
parent bcb7aeac64
commit fd86910ae3
@@ -19,7 +19,6 @@ import axios, { type AxiosInstance } from "axios";
import crypto from "crypto";
import { wrapper } from "axios-cookiejar-support";
import { CookieJar } from "tough-cookie";
import FormData from "form-data";
import type {
EpayCartResponse,
EpaySearchResult,
@@ -400,16 +399,18 @@ export class EpayClient {
configurationUrl: "http://www.google.com",
};
const form = new FormData();
form.append("reqType", "saveProductMetadataForBasketItem");
form.append("productMetadataJSON", JSON.stringify(metadata));
// Use URLSearchParams instead of multipart FormData
// (axios + cookie-jar has issues with native FormData)
const form = new URLSearchParams();
form.set("reqType", "saveProductMetadataForBasketItem");
form.set("productMetadataJSON", JSON.stringify(metadata));
const response = await this.client.post(
`${BASE_URL}/EpayJsonInterceptor.action`,
form,
form.toString(),
{
headers: {
...form.getHeaders(),
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest",
},
timeout: DEFAULT_TIMEOUT_MS,