// edit.vue post文章
methods: {
submit() {
// axios.post('/api/blog', {
// category: this.input.category,
// tag: this.input.tag,
// desc: this.input.desc,
// author: this.input.author,
// image: this.input.image,
// title: this.input.title,
// content: this.input.content
// }).then((res) => {
// const {statusCode, msg} = res.data
// console.log(msg)
// if (statusCode === 1) {
// return msg
// }
// }).catch((e) => {
// console.log('error')
// })
postBlog({
category: this.input.category,
tag: this.input.tag,
desc: this.input.desc,
author: this.input.author,
image: this.input.image,
title: this.input.title,
content: this.input.content
}).then((res) => {
console.log(res)
})
}
},
//api/index.js
const postBlog = post('/blog')
// api/helper.js
export function post(url) {
return function (params) {
return axios.post(baseUrl + url,
// qs.stringify({params})
{params}
).then((res) => {
const {statusCode, msg} = res.data
console.log(res.statusCode)
})
}
}