huynhsamha/js-convert-case

Possible to convert an array directly?

jimmiejackson414-zz opened this issue · 1 comments

Just discovered that I'm unable to convert an array unfortunately.

const data = [
  { id: 1, user_id: 1, created_at: '2021-07-20T15:40:20.170121+00:00'}, 
  {id: 2, user_id: 2, created_at: '2021-07-20T15:40:20.170121+00:00'},
];

const response = camelKeys(data, {
  recursive: true,
  recursiveInArray: true,
});
console.log(response); // returns null

Are there any plans to allow for this feature?

Hi @jimmiejackson414,

Sorry for the late reply. For your case, since your data type is structured, a workaround can be as follows

const response = data.map(x => camelKeys(x))