如何使用axios创建补丁请求


axios.post('/api/v1/users',
{ "edited_field": "email", "email": email },
{ headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': crsfToken }, }
).then((response) => {
// Code
}).catch((error) => {
// Code
})

我有这个post方法,但我想创建一个补丁方法。我见过一些解决方案,他们发布了一个输入值为"patch"的表单,但由于我没有使用表单,我不知道必须如何完成。

欢迎任何帮助:D

提前感谢!

Axios有一个内置的补丁方法。您可以通过将axios.post替换为axios.patch来修改当前的代码
axios.patch('/api/v1/users',
{ "edited_field": "email", "email": email },
{ headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': crsfToken }, }
).then((response) => {
// Code
}).catch((error) => {
// Code
})

最新更新