score:2
data is an object already, if you put it inside a nested objet (body in this case) the map function of the encode method returns "object&object" because is an object.
you need to eliminate the body property inside the fetch function and spread the data objet in order to be iterable for the encode function.
change this:
fetch('/', {
method: 'post',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
body: encode({
'form-name': 'react-validation-form',
body: data,
}),
})
for this
fetch('/', {
method: 'post',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
body: encode({
'form-name': 'react-validation-form',
...data,
}),
Source: stackoverflow.com
Related Query
- I am using React Hook Form with Typescript, string does not accept incoming data
- React Hook Form - Errors not working for multiple forms on a single page for react hook form v7.5.2
- React Hook useEffect async fetch data not passing to tooltip material ui component
- react hook form: materail ui: Textfield: onSubmit, not passing Filelist in the data
- React Hook Form V7 - Material UI 5 Autocomplete: Lazy loaded values not validated
- React Hook Form Error - Type 'UseFormRegister<FormData>' is not assignable to type 'LegacyRef<HTMLInputElement> | undefined'
- Typescript error: Type 'string' is not assignable to type '"allName" | `allName.${number}.nestedArray`' in react hook form
- The validation errors are not showing using React Hook Form
- React Native + Expo + Axios file upload not working because axios is not sending the form data to the server
- React hook form - Register field not working
- TypeError: e.preventDefault is not a function on React Hook Form using EmailJs
- Fields are not editable using React Hook Form
- React with Antd Form onFinish not retrieve data
- @mui v5 Autocomplete with React Hook Form 7 not working?
- React Hook Form V7 + Material UI 5: Default values not validated
- Upload image in react does not return form data values
- Passing Material-UI Data Grid onSelectionChange to a react hook
- React router dom passing data from parent component to child router component does not pass the props.match
- React component not re-rendering on URL parameter change when using useEffect hook to fetch data
- Is there a way to set defaultValues in a child component using react hook form with useFieldArray hook - not using the useForm hook?
- React Hook Form Register Different Forms With Same Field Names
- React hook form does not work with input from reactstrap
- Custom react hook to set input form not working
- Passing data from child to parent component not working in react
- React 'useContext' hook not re-rendering after context updates with database data
- TypeError: register is not a function using React Hook Form in React
- React Hook Form errors not working with Chakra UI
- Submit a form with data using a custom React hook
- Files not getting uploaded from react hook forms to backend server
- react-hook-forms & Netlify. Not passing form data
More Query from same tag
- React native: invoke method dynamically
- How can I access the original names of my input fields, in dot notation, from formik context?
- Sending emails using next.js API after creating a user ERR_HTTP_HEADERS_SENT
- Sharing object aroung Components in React.JS
- Creating a Load More button that increases the amount of visible articles that were fetched from an API
- Redux - How to add item into certain property
- Next js: open index.js on visiting '/blogs/'
- React JS: Rendered fewer hooks than expected. This may be caused by an accidental early return statement
- Not able to load .ttf in React
- React return within render
- onClick doesn't fire at all times
- Using webpack and jspm and external dependencies
- Unable to convert class component to function component
- How to conditionally render a component from the property of a constant in React?
- I need to access data in the object message: "{'data':{'status':'active'}}". it throws error while access while stringfy
- How to Call multiple Functions inside a Render in React/Jsx
- Ionic popover with React - How to make it sticky to the button
- Apollo cache.modify update slower than setState while using in React Beautiful Drag and Drop
- Date object from react-datepicker not getting saved
- _.map values from object into field names for another object?
- How to mock onPast event with React and Jest?
- Custom function in function chain - To get Length of Array
- How to query Wordpress relational fields with GraphQL?
- VictoryPie Custom Colors
- How to useRef in Hoc for html element using typescript
- What is wrong with the React components Route?
- Inline transition duration weird behavior
- JSX: less redundant way to pass props
- React custom checkbox input component not rerendering
- ReactJS Render not firing after data sort