Skip to content

Commit

Permalink
fix(storyblok): set page data on mounted when in editor (#177)
Browse files Browse the repository at this point in the history
* fix(storyblok): set page data on mounted when in editor

* fix(storyblok): remove this.app in mounted

* fix(storyblok): object assign for vue reactivity

* fix(storyblok): set story data on vm

* fix(storyblok): object merge story for reactivity
  • Loading branch information
shadow81627 committed Feb 14, 2020
1 parent 26b912f commit d6b934a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,28 @@ export default {
data() {
return { story: { content: {} } };
},
mounted() {
// Check if we are in the editor mode
if (this.$route.query._storyblok) {
// Load the JSON from the API
this.$storyapi
.get('cdn/stories/home', {
version: 'draft',
})
.then((res) => {
this.story = { ...this.story, ...res.data.story };
})
.catch((res) => {
if (res.response) {
this.error({
statusCode: res.response.status,
message: res.response.data,
});
} else {
console.error(res);
}
});
}
},
};
</script>

1 comment on commit d6b934a

@vercel
Copy link

@vercel vercel bot commented on d6b934a Feb 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.