Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

invalid moment object when converting string to moment inside camelizeKeys #55

Open
pirey opened this issue Oct 22, 2018 · 1 comment
Open

Comments

@pirey
Copy link

pirey commented Oct 22, 2018

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' ?

@pirey
Copy link
Author

pirey commented Oct 22, 2018

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().

@pirey pirey changed the title invalid moment object when converting string to Moment inside camelizeKeys invalid moment object when converting string to moment inside camelizeKeys Oct 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant