From d633e90874f90ebb4af014773eba65e32ac6167c Mon Sep 17 00:00:00 2001 From: Frostyfrog Date: Sat, 25 Nov 2023 19:37:15 -0700 Subject: [PATCH] Avoid saving product data if nothing was returned (#101) * fix: Check if productData is set first Throughout my testing and debugging, it was possible for productData to be "undefined". To prevent errors, it's best to check for it's existence first. Signed-off-by: Colton Wolkins (Laptop) * fix: avoid saving wishlist when there's no change Signed-off-by: Colton Wolkins (Laptop) --------- Signed-off-by: Colton Wolkins (Laptop) --- src/structures/Wishlist.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/structures/Wishlist.js b/src/structures/Wishlist.js index 927b0b4..cb2b7bf 100644 --- a/src/structures/Wishlist.js +++ b/src/structures/Wishlist.js @@ -161,6 +161,8 @@ class Wishlist { } const productData = await getProductData(item.url) + if (!productData) return; // short-circuit when there's no data + for (const key of ['name', 'price', 'image']) { if (productData[key]) item[key] = productData[key] }