convert object to form-data
npm install objecttoformdataconverterWith npm:
```
$ npm install objecttoformdataconverter `
With yarn: `
$ yarn add objecttoformdataconverter `
With pnpm: `
$ pnpm install objecttoformdataconverterUsage
$3
Lets assume we have our data as
``
const data = {
name: 'biju',
age: '20',
address: {city:'dharan', state: 'koshi'}
}`
We can simply convert the provided data by doing`
import { objectToFormData } from "objecttoformdataconverter";
const convertedData = objectToFormData(data)`
The above code produces equivalent of:`
const convertedData = new FormData()
convertedData.append("name", "value")
convertedData.append("age", "value")
convertedData.append("address.city", "value")
convertedData.append("address.state", "value")`$3
Lets assume we have our data as`
const data = {
name: 'biju',
address: [{city:'dharan'},{city:'kathmandu'}]
}`
We can simply convert the provided data by doing`
import { objectToFormData } from "objecttoformdataconverter";
const newData = objectToFormData(data)
The above code produces equivalent of:
```
const newData = new FormData()
newData.append("name", "value")
newData.append("address[0].city", "value")
newData.append("address[1].city", "value")