The idea of form data is to make easy form handling as well as API call. This library is highly inspired by the way that [inertiajs](https://inertiajs.com/) handles form and page visit.
npm install vue3-formjs``bash`
yarn add vue3-formjs
Formjs can be used to send form data through api.
`vue
`
Form js provides fluent api to handle form.
`vue
`
To submit the form, use the get, post, put, patch and delete methods.
`js`
form.submit(method, url, options)
form.get(url, options)
form.post(url, options)
form.put(url, options)
form.patch(url, options)
form.delete(url, options)
It can be used to perform api call. This can be done with
Http.visit() method.
`js
import { Http } from "vue3-formjs"
Http.visit(url, {
method: 'get',
data: {},
onSuccess: response => {},
onError: errors => {},
onFinish: () => {},
})
`
However, there are other shortcut methods as well, where all the methods share same options as Http.visit().
`js
import { Http } from "vue3-formjs"
Http.get(url, data, options)
Http.post(url, data, options)
Http.put(url, data, options)
Http.patch(url, data, options)
Http.delete(url, options)
`
Form js also provides a number of per call event callbacks.
`js
import { Http } from "vue3-formjs"
Http.post('/users', data, {
onSuccess: (response) => {},
onError: (errors) => {},
onFinish: () => {},
})
``