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) <colton@indicio.tech> * fix: avoid saving wishlist when there's no change Signed-off-by: Colton Wolkins (Laptop) <colton@indicio.tech> --------- Signed-off-by: Colton Wolkins (Laptop) <colton@indicio.tech>
This commit is contained in:
parent
b3146d339f
commit
d633e90874
1 changed files with 2 additions and 0 deletions
|
@ -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]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue