Skip to content

Commit

Permalink
send data to .org
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Nov 22, 2023
1 parent 966e156 commit 6de79b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/off.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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(),
Expand All @@ -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 }) {
Expand All @@ -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()}`)
}
};

Expand Down
1 change: 0 additions & 1 deletion src/pages/ingredients/useData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down

0 comments on commit 6de79b5

Please sign in to comment.