Using underscore, how can I replace each data.type key with its corresponding object from example.
For example, I have:
var example = [
{
id: 1,
data: {
type: '/api/data/1/'
}
},
{
id: 2,
data: {
type: '/api/data/2/'
}
},
];
And this:
var data = [
{
id: 1,
uri: '/api/data/1/'
},
{
id: 2,
uri: '/api/data/2/'
}
];
Would like to produce:
var example = [
{
id: 1,
data: {
type: {
id: 1,
uri: '/api/data/1/'
}
}
},
{
id: 2,
data: {
type: {
id: 2,
uri: '/api/data/2/'
}
}
},
];