0
Given a call from event onSubmit
in any form that activates a function, how can I receive the event object along with other properties?
demonstration:
const handleSubmit = async (
// OBJETO DE EVENTO
// AS DEMAIS PROPRIEDADES QUE PASSEI PARA O 'userData'
) => {
event.preventDefault()
const userData = {
firstName,
lastName,
username,
email,
...(phone && { phone }),
...(mobilePhone && { mobilePhone }),
password,
confirmPassword,
...(expireDate && { expireDate }),
status,
profile,
company
}
const parsedUserdata = new URLSearchParams(userData)
try {
await api.post('/users', parsedUserdata)
window.location = '/users-list'
} catch (error) {
console.log(error)
}
}
REMARKS:
I’ve tried to pass the event and a breakdown of my props, but it doesn’t work:
const handleSubmit = async ( e, { firstname, lastName}) => {...}