1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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
- }
- },
- async updateBlog({commit, state}, {data, id}) {
- try {
- console.log('instructor/blog.js actions updateBlog call axios.$patch-> Id, data')
- const blog = await this.$axios.$patch(`/api/v1/blogs/${id}`, data)
- console.log('instructor/blog.js actions updateBlog done axios.$patch-> Id, data')
- console.log('courses.js mutations call setBlog')
- commit('setBlog', blog)
- console.log('courses.js mutations done setBlog')
- return state.item
- } catch (error) {
- return error
- }
- }
- }
- export const mutations = {
- setBlog(state, blog) {
- state.item = blog
- }
- }
|