I want to save an array of object ids in the database but it receives as a plain string from the frontend. the useState hook: const [package_ids, setPackage_Ids] = useState([]); I am appending this ids in the formdata: formData.append("package_ids", package_ids); The code where admin selects the packageIds:
<Form.Group controlId="package_ids">
<Form.Label>Select Package/s:</Form.Label>
{packages.map((item) => (
<Form.Check
key={item._id}
type="checkbox"
label={item.name}
onChange={(e) =>
setPackage_Ids((c) =>
e.target.checked
? [...c, item._id]
: c.filter((el) => el !== item._id)
)
}
/>
))}
</Form.Group>
If I log the packageids in the front-end it logs as an array and in the backend I am using app.use(express.json())