瀏覽代碼

icon

cart-api-guide
azri 4 天之前
父節點
當前提交
2ff901dc43
共有 4 個檔案被更改,包括 15 行新增13 行删除
  1. 二進制
      public/favicon.ico
  2. 二進制
      public/favicon_bak.ico
  3. 1
    1
      public/index.html
  4. 14
    12
      src/services/ProductService.js

二進制
public/favicon.ico 查看文件


二進制
public/favicon_bak.ico 查看文件


+ 1
- 1
public/index.html 查看文件

@@ -24,7 +24,7 @@
24 24
       work correctly both with client-side routing and a non-root public URL.
25 25
       Learn how to configure a non-root public URL by running `npm run build`.
26 26
     -->
27
-    <title>React App</title>
27
+    <title>AMBER</title>
28 28
   </head>
29 29
   <body>
30 30
     <noscript>You need to enable JavaScript to run this app.</noscript>

+ 14
- 12
src/services/ProductService.js 查看文件

@@ -5,26 +5,28 @@ import { API_URL, REACT_APP_API_KEY, REACT_APP_API_SECRET, REACT_APP_ACCESS_TOKE
5 5
 const shopUrl = REACT_APP_SHOP_NAME;
6 6
 const accessToken = REACT_APP_ACCESS_TOKEN;
7 7
 
8
+const client = createStorefrontApiClient({
9
+  storeDomain: `https://${shopUrl}/api/2024-10/graphql.json`,
10
+  apiVersion: '2024-10',
11
+  publicAccessToken: accessToken,
12
+});
8 13
 
9
-const getProducts = async () => {
10
-
11
-  console.log(shopUrl)
12
-  console.log(accessToken)
13
-  console.log(createStorefrontApiClient)
14 14
 
15
-  const client = createStorefrontApiClient({
16
-    storeDomain: `https://${shopUrl}/api/2024-10/graphql.json`,
17
-    apiVersion: '2024-10',
18
-    publicAccessToken: accessToken,
19
-  });
15
+const getProducts = async () => {
20 16
 
21 17
   const productQuery = `
22 18
     {
23 19
       products(first: 99) {
24 20
         nodes {
25
-          id
21
+          media(first: 4) {
22
+            nodes {
23
+              previewImage {
24
+                url
25
+              }
26
+            }
27
+          }
26 28
           title
27
-          totalInventory
29
+          tags
28 30
         }
29 31
       }
30 32
     }

Loading…
取消
儲存