[Vuejs]-What are the main differences between Inertia's useForm() and axios requests?

0👍

useForm is just an object wrapper that has pre-defined method you can use, you can take a look at the source code here.

e.i you can use transform, post, reset with a callback onFinish

import { useForm } from '@inertiajs/vue3'

const form = useForm({
    email: null,
    password: null,
    remember: null
})

const submit = () => {
    form.loading = true
    form.transform(data => ({
        ...data,
        remember: form.remember ? 'on' : '',
    })).post('/url', {
        onFinish: () => { 
            form.loading = false
            form.reset('password')
        },
    });
}

the HTTP request from useForm are using inertia router which also uses axios,

So;

useForm – is an object form helper that also uses axios

axios – is a full HTTP library

Leave a comment