humps
humps copied to clipboard
invalid moment object when converting string to moment inside camelizeKeys
when i try to camelize my object, i want to convert one of the field (string) into moment object, like this
const p = camelizeKeys({
...myobject,
timestamp: moment(purchase.timestamp),
});
the camelization is ok, no error.
the thing is, moment object suppose to have .format
function defined on the object.
but when i try to access it from p.timestamp.format
it said that format
is undefined.
what is the cause of that? how to do it 'properly' ?
for now, i do have workaround for that, i separate the camelization with the string-to-moment conversion, like this
const p = camelizeKeys({
...myObject,
})
p.timestamp = moment(p.timestamp);
with that, i can access the p.format()
.