|
@@ -4,43 +4,43 @@ export const state = () => ({
|
|
|
})
|
|
|
|
|
|
export const actions = {
|
|
|
- async createBlog(_, blogData) {
|
|
|
- try {
|
|
|
- commit('setIsSaving', true)
|
|
|
- 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')
|
|
|
+ async createBlog({commit}, blogData) {
|
|
|
+ commit('setIsSaving', true)
|
|
|
+ console.log('instructor/blog.js actions createBlog call axios.$post->blogData')
|
|
|
+ const blog = await this.$axios.$post('/api/v1/blogs', blogData)
|
|
|
+ if(blog.isAxiosError === true){
|
|
|
commit('setIsSaving', false)
|
|
|
- return blog
|
|
|
- } catch (error) {
|
|
|
- commit('setIsSaving', false)
|
|
|
- return error
|
|
|
+ console.log(blog.data)
|
|
|
+ return Error('')
|
|
|
}
|
|
|
+ console.log('instructor/blog.js actions createBlog done axios.$post->blogData')
|
|
|
+ commit('setIsSaving', false)
|
|
|
+ return blog
|
|
|
},
|
|
|
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
|
|
|
+ console.log('instructor/blog.js actions fetchBlogById call axios.$get->blogId')
|
|
|
+ const blog = await this.$axios.$get(`/api/v1/blogs/${blogId}`)
|
|
|
+ if(blog.isAxiosError === true){
|
|
|
+ console.log(blog.data)
|
|
|
+ return Error('')
|
|
|
}
|
|
|
+ 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')
|
|
|
},
|
|
|
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
|
|
|
+ console.log('instructor/blog.js actions updateBlog call axios.$patch-> Id, data')
|
|
|
+ const blog = await this.$axios.$patch(`/api/v1/blogs/${id}`, data)
|
|
|
+ if(blog.isAxiosError === true){
|
|
|
+ console.log(blog.data)
|
|
|
+ return Error('')
|
|
|
}
|
|
|
+ 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
|
|
|
}
|
|
|
}
|
|
|
|