I need object to convert to array and push to array. Depending on what is chosen, I get it like this ->
{
firstUnit: {label: 'caca', value: 70}
secondUnit: {label: 'Parent 2', value: 9}
}
Or sometimes i got only
{
firstUnit: {label: 'caca', value: 70}
}
or
{
secondUnit: {label: 'Parent 2', value: 9}
}
What I need ?
I need to convert this
{
firstUnit: {label: 'caca', value: 70}
secondUnit: {label: 'Parent 2', value: 9}
}
or
{
firstUnit: {label: 'caca', value: 70}
}
TO
[ {label: 'caca', value: 70} , {label: 'Parent 2', value: 9}]
or if only one object
[{label: 'caca', value: 70}]
What I am try ?
let formVal = [formValues];
let newVal = [formVal?.map((values) => values)]
This is no work property.
const newVal = Object.entries(formValues);might help you.