fetching blogs and articles

This commit is contained in:
thomas
2020-02-27 20:22:03 +01:00
parent 97a8b136f0
commit c00452f3d0
10 changed files with 136 additions and 20 deletions
+20 -3
View File
@@ -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) => {