forked from pavelloz/webpack-tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
113 lines (94 loc) · 2.62 KB
/
app.js
File metadata and controls
113 lines (94 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import '../css/app.css';
import Alpine from 'alpinejs'
import axios from 'axios';
window.axios = require('axios');
window.Alpine = Alpine
Alpine.directive('uppercase', el => {
el.textContent = el.textContent.toUpperCase()
})
const Products = () => {
const data = JSON.stringify({
query: `query FetchProductSample {
product(handle: "main-roast") {
id
title
variants(first: 15) {
edges {
node {
id
title
sku
priceV2 {
amount
}
image {
url(transform: {maxWidth: 300})
altText
}
selectedOptions {
name
value
}
}
}
}
}
}`,
variables: {}
});
const config = {
method: 'post',
url: 'https://lifeboostcoffee.myshopify.com/api/2022-04/graphql.json',
headers: {
'X-Shopify-Storefront-Access-Token': 'f81f808b4e00de733d0e8195d5e0c6a9',
'Content-Type': 'application/json'
},
data: data
};
return {
itemIds() {
return this.$store.productStore.products
},
async getItems() {
let vm = this;
return axios(config).then((response) => {
Alpine.store('productStore', {
products: response.data.data.product.variants.edges,
async getVar(roast, type) {
return this.products.filter(product => {
return product.node.title.toLowerCase().includes(type.toLowerCase()) && product.node.title.toLowerCase().includes(roast.toLowerCase())
})
}
})
console.log(vm);
}).catch((error) => {
console.log(error)
})
},
}
}
console.log(Products().getItems());
Alpine.data('roast', () => ({
roast: 'light',
setRoast(roast) {
this.roast = roast
}
}))
Alpine.data('type', () => ({
type: 'beans',
setType(type) {
this.type = type
}
}))
Alpine.store('productStore', {
products: {},
// axios(config).then(function(response) {
// this.products = response.data.data.product.variants.edges
// })
// .catch(function(error) {
// console.log(error);
// });
})
Alpine.start()
import ( /* webpackChunkName: "myModule", webpackPrefetch: true */ './dynamic_import').then(module => module.default());
console.log('Hello from app.js');