Refactor product ID retrieval to dynamically fetch from API instead of hardcoding values, enhancing flexibility for future updates.
This commit is contained in:
14
index.js
14
index.js
@@ -6,9 +6,6 @@ const fs = require("fs");
|
||||
const discordWebhook =
|
||||
"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) {
|
||||
axios.post(discordWebhook, {
|
||||
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() {
|
||||
const productsIds = await getProducts();
|
||||
const products = [];
|
||||
|
||||
for (const productId of productsIds) {
|
||||
|
||||
Reference in New Issue
Block a user