OK folks, has anyone seen this effect when using wix-router?
Wix team not sure this is this a feature or a bug. I am however erring on the side of it being a bug.
I have a date field in a data collection that I want to retrieve in my router and then pass to my page using the [routerReturnedData: Object] parameter of the ok() function.
So I have an object (a raw record from the data collection) which I pass to the ok function.
When I pull the record from the getRouterData() function on my page the record has been miraculously changed. To verify this phenomenon I sent a JSON version of the object along with the actual object from my router and this is what I get:
JSON version of Original Object:
{"_id":"89626c76-41a5-4011-bafb-b936c88437e1",
"guestId":"d862cc5c-0e45-4f62-be1b-1e6299fa4ed3",
"guestNotes":"Stuff",
"requested":"2018-07-26T13:31:33.184Z",
"_createdDate":"2018-07-26T13:31:39.137Z",
"_updatedDate":"2018-07-26T13:31:39.137Z"}
This arrives in an object as follows:
{"guestId":"d862cc5c-0e45-4f62-be1b-1e6299fa4ed3",
"guestNotes":"Stuff",
"requested":{"$date":"2018-07-26T13:31:33.184Z"},
"_createdDate":{"$date":"2018-07-26T13:31:39.137Z"},
"_id":"89626c76-41a5-4011-bafb-b936c88437e1",
"_updatedDate":{"$date": "2018-07-26T13:31:39.137Z"}}
So basically the Wix api code has (possibly for JSON encoding purposes though it doesn’t appear necessary) adjusted the original record and altered the date fields by turning them into Objects by adding the key “$date”. It has then forgotten to rewind this adjustment when getRouterData() is called :-(.
Cheers Steve