互联网技术 · 2024年2月15日

关于axios请求的delete方法

有的人只知道delete方法,传值的时候,将请求值放在url上,而像post方法那些,带有请求体,却不知道该如果传值。

首先,delete方法有三种写法

一:请求参数拼接在url上

axios.delete(/delete, {

params: { // 请求参数拼接在url上

id: 12

}

}).then(res => {

console.log(res)

})

二:请求参数放在请求体

axios.delete(/delete, {

data: { // 请求参数放在请求体

id: 12

}

}).then(res => {

console.log(res)

})

三:请求参数拼接在url上或请求参数放在请求体

axios({

method: delete,

url: /delete,

params: {}, // 请求参数拼接在url上

data: {} // 请求参数放在请求体

}).then(res => {

console.log(res)

})

文章来源:田珊珊个人博客

来源地址:http://www.tianshan277.com/796.html

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.