@nuskin/ns-product-lib 2.17.0-cx24-5822.7 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.17.0-cx24-5822.7",
3
+ "version": "2.17.0",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -145,12 +145,16 @@ async function getProducts(ids, market, locale, config) {
145
145
 
146
146
  function mapSkusToProducts(skus , products){
147
147
  const productsData = [];
148
- if (products?.data?.productsById?.products?.length) {
148
+ if (products &&
149
+ products.data &&
150
+ products.data.productsById &&
151
+ products.data.productsById.products &&
152
+ products.data.productsById.products.length) {
149
153
  skus.forEach((sku)=>{
150
154
  const matchedProducts = products.data.productsById.products.filter((product)=>{
151
155
  let matched = false;
152
- if(product?.id) {matched = product.id === sku;}
153
- if(product?.variants?.length){
156
+ if(product.id) {matched = product.id === sku;}
157
+ if(product.variants.length){
154
158
  product.variants.forEach((variant)=>{
155
159
  matched |= variant.sku === sku;
156
160
  });