调用接口时发现content-type格式和接口要求不符
需要把content-type设置为application/json
正常给axios设置headers: { 'Content-Type': 'application/json' },查看请求头,并没有添加上
找了些资料发现,axios在不传data的情况下无法设置content-type
于是给传个data
.$api({
method: 'delete',
url: '/Case/DelCase',
params,
data: {}, // 不设置data,无法设置Content-Type
headers: { 'Content-Type': 'application/json' },
})
.then((res) => {
if (res.Tag === 1) {
//
}
})
.catch(() => {})
.finally(() => {})
加上data:{}后,成功