I am trying to achieve a data structure in javascript that looks like this:
settings: {
{ "key": "Language", "value": "en" },
{ "key": "Language", "value": "en" }
}
The amount of keys is variable and needs to be iterated over. I thought I could do it with an array but the [0] numbers are getting in the way.
This is what i have now:
convertSettingsToApiSaveFormat(values) {
const keys = Object.keys(values);
const items = Object.values(values);
const valuesToSend = keys.map((key, i) => {
return { key, value: items[i] };
});
return { settings: [valuesToSend] };
}
}
any help is much appreciated!

values?{}, thekey nameis required to hold a valuereturn {settings: valuesToSend}- it's already an array.