diff --git a/src/off.ts b/src/off.ts index 33affb7e84..edc2bc2e6e 100644 --- a/src/off.ts +++ b/src/off.ts @@ -4,6 +4,7 @@ import { OFF_API_URL_V2, OFF_IMAGE_URL, OFF_SEARCH, + OFF_URL, } from "./const"; import axios from "axios"; import combineURLs from "axios/lib/helpers/combineURLs"; @@ -116,7 +117,7 @@ const offService = { }`; }, - searchProducts({ page = 1, pageSize = 25, filters = [], fields='code', countryCode = 'world' }) { + searchProducts({ page = 1, pageSize = 25, filters = [], fields = 'code', countryCode = 'world' }) { const searchParams = { page: page.toString(), page_size: pageSize.toString(), @@ -133,8 +134,9 @@ const offService = { }); }); + console.log({ countryCode }) const urlParams = new URLSearchParams(searchParams); - return axios.get(`${OFF_SEARCH.replace('worlds.', `${countryCode || 'world'}.`)}?${urlParams.toString()}`); + return axios.get(`${OFF_SEARCH.replace('world.', `${countryCode}.`)}?${urlParams.toString()}`); }, setIngedrient({ code, lang, text }) { @@ -146,7 +148,7 @@ const offService = { } const urlParams = new URLSearchParams({ code, [`ingredients_text${lang ? `_${lang}` : ''}`]: text }); - axios.post(`https://world.openfoodfacts.net/cgi/product_jqm2.pl?${urlParams.toString()}`) + axios.post(`${OFF_URL}/cgi/product_jqm2.pl?${urlParams.toString()}`) } }; diff --git a/src/pages/ingredients/useData.tsx b/src/pages/ingredients/useData.tsx index a93b5fd178..2a21cb57e8 100644 --- a/src/pages/ingredients/useData.tsx +++ b/src/pages/ingredients/useData.tsx @@ -95,7 +95,6 @@ export default function useData(): [any[], () => void, boolean] { page, pageSize: 25, filters: imagesToRead, - countryCode: "ch", fields: "code,lang,image_ingredients_url,product_name,ingredient,images", });