Refactor product ID retrieval to dynamically fetch from API instead of hardcoding values, enhancing flexibility for future updates.

This commit is contained in:
Norbert Maciaszek
2025-11-16 19:22:16 +01:00
parent 72ba9aae20
commit 63bae4f805

View File

@@ -6,9 +6,6 @@ const fs = require("fs");
const discordWebhook = const discordWebhook =
"https://discord.com/api/webhooks/1439286509390921749/t2Hb8XloF6zhDRYD1yh_QlkHHa9eHUyXvd9TxZRHwqR_b_OxxbnwDgsm4em8TwA9NQIa"; "https://discord.com/api/webhooks/1439286509390921749/t2Hb8XloF6zhDRYD1yh_QlkHHa9eHUyXvd9TxZRHwqR_b_OxxbnwDgsm4em8TwA9NQIa";
// new version works with ceneo.pl only
const productsIds = ["182928416", "95706396", "90180325"];
function sendMessage(message) { function sendMessage(message) {
axios.post(discordWebhook, { axios.post(discordWebhook, {
content: message, content: message,
@@ -57,7 +54,18 @@ async function compareAndSave(productsPrice) {
); );
} }
async function getProducts() {
const products = await axios
.get(
"https://db.maciaszek.ovh/api/collections/gifts_items/records?fields=ceneo_id&filter=ceneo_id!=''"
)
.then((response) => response.data.items.map((item) => item.ceneo_id));
return products;
}
async function init() { async function init() {
const productsIds = await getProducts();
const products = []; const products = [];
for (const productId of productsIds) { for (const productId of productsIds) {