12345678910111213141516171819202122232425262728293031323334 |
- export const state = () => ({
- item: {}
- })
- export const actions = {
- async createBlog(_, blogData) {
- try {
- console.log('instructor/blog.js actions createBlog call axios.$post->blogData')
- const blog = await this.$axios.$post('/api/v1/blogs', blogData)
- console.log('instructor/blog.js actions createBlog done axios.$post->blogData')
- return blog
- } catch (error) {
- return error
- }
- },
- async fetchBlogById({commit}, blogId) {
- try {
- console.log('instructor/blog.js actions fetchBlogById call axios.$get->blogId')
- const blog = await this.$axios.$get(`/api/v1/blogs/${blogId}`)
- console.log('instructor/blog.js actions fetchBlogById done axios.$get->blogId')
- console.log('courses.js mutations call setBlog')
- commit('setBlog', blog)
- console.log('courses.js mutations done setBlog')
- } catch (error) {
- return error
- }
- }
- }
- export const mutations = {
- setBlog(state, blog) {
- state.item = blog
- }
- }
|