const { form, errors } = createForm({
onSubmit: async (values, { event }) => {
try {
const formData = new FormData(event.target)
const response = await fetch('/api/login', {
method: 'POST',
body: formData,
})
const data = await response.json()
return data
} catch (error) {
console.warn('Fetch call failed')
console.error(error)
// You might want to handle the error or return some indication of failure
throw error
}
},
onSuccess(response, context) {
// Do something with the returned value from `onSubmit`.
},
onError(err, context) {
// Do something with the error thrown from `onSubmit`.
console.log('test err: ', err)
},
})
const { form, errors } = createForm({
onSubmit: async (values, { event }) => {
try {
const formData = new FormData(event.target)
const response = await fetch('/api/login', {
method: 'POST',
body: formData,
})
const data = await response.json()
return data
} catch (error) {
console.warn('Fetch call failed')
console.error(error)
// You might want to handle the error or return some indication of failure
throw error
}
},
onSuccess(response, context) {
// Do something with the returned value from `onSubmit`.
},
onError(err, context) {
// Do something with the error thrown from `onSubmit`.
console.log('test err: ', err)
},
})