I'm importing some json from another files using es6 but when i try to gather them inside of another json object they added with variable name as array name.
element1.js
module.exports = {
'element1': { foo: 'bar' }
}
element2.js
module.exports = {
'element2': { foo: 'bar' }
}
when i run this code below;
import elementVar1 from './element1.js'
import elementVar2 from './element2.js'
const list = { elementVar1, elementVar2 }
list returns as below;
{
elementVar1: {
element1: {
foo: 'bar'
}
},
elementVar2: {
element2: {
foo: 'bar'
}
}
}
my aim is process these elements without any wrapper like this;
{
element1: {
foo: 'bar'
},
element2: {
foo: 'bar'
}
}
basicly i want to concat them