Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to create an patch request with 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
        })

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
        })
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading