Selaa lähdekoodia

icon

cart-api-guide
azri 4 päivää sitten
vanhempi
commit
2ff901dc43
4 muutettua tiedostoa jossa 15 lisäystä ja 13 poistoa
  1. BIN
      public/favicon.ico
  2. BIN
      public/favicon_bak.ico
  3. 1
    1
      public/index.html
  4. 14
    12
      src/services/ProductService.js

BIN
public/favicon.ico Näytä tiedosto


BIN
public/favicon_bak.ico Näytä tiedosto


+ 1
- 1
public/index.html Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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…
Peruuta
Tallenna