1.post请求,payload要formdata格式
文档上面调试显示的格式:x-www-form-urlencoded
在文档上面发送请求,看到payload要formdata格式
解决:接口加上header
export const delImagePoll = (data) => {
return request({
url: "/tech_proposal/api/imagePoll/delete",
data: data,
headers: {//加上headers
"Content-Type": "application/x-www-form-urlencoded",
},
method: "post",
});
};
2. post 请求参数既有query又有body
在文档上面发送请求,看到payload的格式
params一般是接在url后面
所以:query参数接在url后面,strings 作为data
const handleImagePoll = (code) => {
let strings = [code]
imagePoll(galleryId.value, strings ).then(res => {
getPicList()
ElMessage({
type: 'success',
message: '添加图片成功',
})
})
}
//api.js
export const imagePoll = (galleryId, data) => {
return request({
url: "/tech_proposal/api/imagePoll?galleryId=" + galleryId,
data: data,
method: "post",
});
};