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
})
I have this post method, but i want to create an patch method of this. i have seen some solutions where they post a form with an input value=’patch’ but since im not using a form i have no idea how it must be done.
Any help is welcome 😀
Thanks in advance!
>Solution :
Axios has a built-in patch method. You can modify the code you currently have by replacing axios.post with 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
})