fetching blogs and articles
This commit is contained in:
+13
-1
@@ -1,12 +1,24 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Blog</h1>
|
||||
{{ articles }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Index'
|
||||
name: 'Index',
|
||||
asyncData ({ app }) {
|
||||
return app.$axios.get('https://home-deco35.myshopify.com/admin/api/2020-01/articles.json', {
|
||||
headers: {
|
||||
'X-Shopify-Access-Token': '99804a726edfba831c6671c3b66f413a'
|
||||
}
|
||||
}).then((response) => {
|
||||
return {
|
||||
articles: response.data
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="hr" />
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<h2 class="is-2">Products in this collection</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<product-card-list
|
||||
@@ -37,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ProductCardList from '../../../components/productCardList'
|
||||
import ProductCardList from '../../../components/ProductCardList'
|
||||
export default {
|
||||
layout: 'noContainer',
|
||||
components: {
|
||||
|
||||
+20
-3
@@ -44,13 +44,30 @@
|
||||
<script>
|
||||
export default {
|
||||
layout: 'noContainer',
|
||||
asyncData ({ $shopify }) {
|
||||
return $shopify.collection.fetchAllWithProducts().then((collections) => {
|
||||
asyncData ({ app }) {
|
||||
return app.$axios.get('https://home-deco35.myshopify.com/admin/api/2020-01/blogs.json', {
|
||||
headers: {
|
||||
'X-Shopify-Access-Token': '99804a726edfba831c6671c3b66f413a'
|
||||
}
|
||||
}).then((response) => {
|
||||
return {
|
||||
collections
|
||||
blogs: response.data.blogs
|
||||
}
|
||||
})
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
collections: []
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.$shopify.collection.fetchAllWithProducts().then((collections) => {
|
||||
this.collections = collections
|
||||
})
|
||||
this.$store.commit('setBlogs', this.blogs)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Blog: ', this.blogs)
|
||||
},
|
||||
beforeUpdate () {
|
||||
if (typeof this.$store.state.checkout.id === 'undefined') {
|
||||
this.$shopify.checkout.create().then((checkout) => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<script>
|
||||
import cartMixins from '../../mixins/cartMixins'
|
||||
import ProductCardList from '../../components/productCardList'
|
||||
import ProductCardList from '../../components/ProductCardList'
|
||||
|
||||
export default {
|
||||
name: 'Index',
|
||||
|
||||
Reference in New Issue
Block a user