奇怪的 Shopify 店面 api 数据使用 shopify-buy 输出

问题描述

按照此处的 shopify 文档进行操作:https://shopify.github.io/js-buy-sdk/?shpxid=b2510128-0B14-4F7D-6073-5655FC3656BB#fetching-products

我尝试像这样从我的商店加载所有产品:

// Fetch all products in your shop
client.product.fetchAll().then((products) => {
  // Do something with the products
  console.log(products);
});

但是我从中得到的输出如下:

[
    {
        "id": "xxx1","availableForSale": true,"createdAt": "2021-07-10T04:00:47Z","updatedAt": "2021-07-10T04:13:09Z","descriptionHtml": "This is a venetian blind!","description": "This is a venetian blind!","handle": "venetian-blind","productType": "","title": "Venetian blind","vendor": "Blinds King","publishedAt": "2021-07-10T04:00:49Z","onlinestoreUrl": null,"options": [
            {
                "id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0T3B0aW9uLzg3NTI0NzcyNDE1MTc=","name": "Title","values": [
                    {
                        "value": "Default Title","type": {
                            "name": "String","kind": "SCALAR"
                        }
                    }
                ],"type": {
                    "name": "ProductOption","kind": "OBJECT","fieldBaseTypes": {
                        "name": "String","values": "String"
                    },"implementsNode": true
                }
            }
        ],"images": [],"variants": [
            {
                "id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC80MDI5MTQyNjc2MjkyNQ==","title": "Default Title","price": "20.00","priceV2": {
                    "amount": "20.0","currencyCode": "AUD","type": {
                        "name": "MoneyV2","fieldBaseTypes": {
                            "amount": "Decimal","currencyCode": "CurrencyCode"
                        },"implementsNode": false
                    }
                },"presentmentPrices": [
                    {
                        "price": {
                            "amount": "20.0","type": {
                                "name": "MoneyV2","fieldBaseTypes": {
                                    "amount": "Decimal","currencyCode": "CurrencyCode"
                                },"implementsNode": false
                            }
                        },"compareAtPrice": null,"type": {
                            "name": "ProductvariantPricePair","fieldBaseTypes": {
                                "compareAtPrice": "MoneyV2","price": "MoneyV2"
                            },"implementsNode": false
                        },"hasNextPage": false,"hasPrevIoUsPage": false,"variableValues": {
                            "first": 20
                        }
                    }
                ],"weight": 0,"available": true,"sku": "2","compareAtPriceV2": null,"image": null,"selectedOptions": [
                    {
                        "name": "Title","value": "Default Title","type": {
                            "name": "SelectedOption","fieldBaseTypes": {
                                "name": "String","value": "String"
                            },"implementsNode": false
                        }
                    }
                ],"unitPrice": null,"unitPriceMeasurement": {
                    "measuredType": null,"quantityUnit": null,"quantityValue": 0,"referenceUnit": null,"referenceValue": 0,"type": {
                        "name": "UnitPriceMeasurement","fieldBaseTypes": {
                            "measuredType": "UnitPriceMeasurementMeasuredType","quantityUnit": "UnitPriceMeasurementMeasuredUnit","quantityValue": "Float","referenceUnit": "UnitPriceMeasurementMeasuredUnit","referenceValue": "Int"
                        },"type": {
                    "name": "Productvariant","fieldBaseTypes": {
                        "availableForSale": "Boolean","compareAtPrice": "Money","compareAtPriceV2": "MoneyV2","id": "ID","image": "Image","presentmentPrices": "ProductvariantPricePairConnection","price": "Money","priceV2": "MoneyV2","product": "Product","selectedOptions": "SelectedOption","sku": "String","title": "String","unitPrice": "MoneyV2","unitPriceMeasurement": "UnitPriceMeasurement","weight": "Float"
                    },"implementsNode": true
                },"variableValues": {
                    "first": 20
                }
            }
        ],"type": {
            "name": "Product","fieldBaseTypes": {
                "availableForSale": "Boolean","createdAt": "DateTime","description": "String","descriptionHtml": "HTML","handle": "String","images": "ImageConnection","onlinestoreUrl": "URL","options": "ProductOption","productType": "String","publishedAt": "DateTime","updatedAt": "DateTime","variants": "ProductvariantConnection","vendor": "String"
            },"implementsNode": true
        },"variableValues": {
            "first": 20
        }
    }
]

这似乎让我返回了 graphql 数据,使用它的最佳方法是什么,因为文档没有为此提供任何指导..

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)