I have a response from my api that returns an object that look like this.
{
"global.edit": "Edit"
},
{
"global.add": "Add"
},
{
"lang.english": "English"
},
{
"lang.french": "French"
},
{
"menu.localGroups": "Label's groups"
},
{
"menu.locals": "Labels"
}
What I am trying to achieve is to convert to a separated comma array.
const MY_NEW_LOCALS_HERE = {
"global.edit": "Edit",
"global.add": "Add",
"lang.english": "English",
"lang.french": "French",
"menu.localGroups": "Label's groups",
"menu.locals": "Labels"
}
So I can add loaded locals to React-Intl.
this.setState({
localMessage: {
...this.state.localMessage,
MY_NEW_LOCALS_HERE,
}
})
I spent hours trying to figure it out but I just can't.
Any help on how to achieve this?
If I use OBJECT.join(',') I get an [object Object],[object Object] array.
reduce()method.