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 crypto from "crypto";
import { wrapper } from "axios-cookiejar-support"; import { wrapper } from "axios-cookiejar-support";
import { CookieJar } from "tough-cookie"; import { CookieJar } from "tough-cookie";
import FormData from "form-data";
import type { import type {
EpayCartResponse, EpayCartResponse,
EpaySearchResult, EpaySearchResult,
@@ -400,16 +399,18 @@ export class EpayClient {
configurationUrl: "http://www.google.com", configurationUrl: "http://www.google.com",
}; };
const form = new FormData(); // Use URLSearchParams instead of multipart FormData
form.append("reqType", "saveProductMetadataForBasketItem"); // (axios + cookie-jar has issues with native FormData)
form.append("productMetadataJSON", JSON.stringify(metadata)); const form = new URLSearchParams();
form.set("reqType", "saveProductMetadataForBasketItem");
form.set("productMetadataJSON", JSON.stringify(metadata));
const response = await this.client.post( const response = await this.client.post(
`${BASE_URL}/EpayJsonInterceptor.action`, `${BASE_URL}/EpayJsonInterceptor.action`,
form, form.toString(),
{ {
headers: { headers: {
...form.getHeaders(), "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest", "X-Requested-With": "XMLHttpRequest",
}, },
timeout: DEFAULT_TIMEOUT_MS, timeout: DEFAULT_TIMEOUT_MS,