This commit is contained in:
hamid zarghami
2025-09-20 11:36:18 +03:30
parent 5adf5fe461
commit 40c3729d65
5 changed files with 173 additions and 9 deletions
+12 -1
View File
@@ -5,7 +5,18 @@ import { CompareResponse } from "../types/Types";
export const getCompare = async (
productIds: string[]
): Promise<CompareResponse> => {
const { data } = await axios.get(`/product/compare?productIds=${productIds}`);
console.log("API call - productIds:", productIds);
// روش اول: ارسال آرایه به صورت جداگانه
const params = new URLSearchParams();
productIds.forEach((id) => {
params.append("productIds", id);
});
console.log("Final URL:", `/product/compare?${params.toString()}`);
const { data } = await axios.get(`/product/compare?${params.toString()}`);
console.log("API response:", data);
return data;
};