mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 22:10:06 +00:00
20 lines
311 B
JavaScript
20 lines
311 B
JavaScript
import { isArray } from 'lodash';
|
|
|
|
function cleanData(value, key) {
|
|
if (isArray(value)) {
|
|
return value.map(obj => {
|
|
if (obj[key]) {
|
|
return obj[key];
|
|
}
|
|
|
|
return obj;
|
|
});
|
|
} else if (_.isObject(value)) {
|
|
return value[key];
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
export default cleanData;
|