请问vue中这个请求,在idea中应该怎么接收呢
export const ModuleDelete = (params) => { return axios.delete("/api/Module/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data) };
Axios是一个基于Promise的HTTP客户端,可以在浏览器和Node.js环境中使用。您可以使用Axios发送HTTP DELETE请求以删除数据。
下面是一个使用Axios发送DELETE请求的示例:
axios.delete('https://jsonplaceholder.typicode.com/posts/1')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
在上面的示例中,我们使用了axios.delete方法发送了一个DELETE请求。该方法接受一个URL作为参数,并返回一个Promise对象。
使用.then方法处理响应数据,并使用.catch方法处理错误。
请注意,在实际应用中,您可能需要使用请求头和请求参数,请参考Axios的官方文档以获取更多信息。
不知道你这个问题是否已经解决, 如果还没有解决的话:示例代码
//参数以明文形式提交
this.$axios.delete('/url',{
params: {
id:1
}
}).then(res=>{
console.log(res.data);
})
//参数以封装对象的形式提交
this.$axios.delete('/url',{
data: {
id:1
}
}).then(res=>{
console.log(res.data);
})
//方法二
axios({
method: 'delete',
url: '/url',
params: { id:1 }, //以明文方式提交参数
data: { id:1 } //以封装对象方式提交参数
}).then(res=>{
console.log(res.data);
})