pikaday-angular icon indicating copy to clipboard operation
pikaday-angular copied to clipboard

Sending off Pikaday object through REST

Open philippeluickx opened this issue 9 years ago • 2 comments

Hey,

I am trying to submit my data through REST and this includes a Pikaday object. Following is the error:

TypeError: Converting circular structure to JSON at Object.stringify (native)

I partially manage to get around by using .getString(), but then I need to check if there is an object (because the function does not work on undefined, in case the date is optional).

Probably something I am overlooking, any suggestion is appreciated!

philippeluickx avatar May 21 '15 12:05 philippeluickx

Hi,

Is there a reason to serialize the whole Pikaday object, including its methods?

nverba avatar May 21 '15 14:05 nverba

I am binding a form including dates. I then submit the model linked to this form to the REST backend through rest-angular. The challenge with pikaday-angular thus is that I would have to replace the dates from the model in the Controller, which is not a huge issue but somehow a bit less elegant.

Furthermore, I am struggling with optional date fields as well.

  1. I can disable a field, which makes that the property on that model is not present. So calling .getString() function will not work, as the date is undefined.
  2. If there is a Pikaday object, but no input, then the .getString() does work. However, in my case I can not simply submit an empty string but I need to delete the property. This however is backend specific...

So this leads to some dirty if-else statements in the code. No big deal, just pointing a potential win here for improvement.

philippeluickx avatar May 21 '15 14:05 philippeluickx