How to deserialize and re-formatter "Date Object" from SAP via Javascript
I working for get data from SAP via REST API and return to work with JSON in Javascript. I want to re-format the date object from type 2021-01-01
to 01/01/2021
.
SAP has the data type Date
but after serialize to JSON format. SAP Date object has be convert to String
data type.
My older code conversion in Javascript is
![](https://kusumotolab.com/content/images/2021/04/image-3.png)
In my source code version 1, I'm not happy for this because hard understand and source code not clarify. I will rewrite this.
![](https://kusumotolab.com/content/images/2021/04/image-4.png)
In my source code version 2, I'm first focus clarify in code. I using the destructuring assignment to get data from string split result and use the functional programming for build the new string format from array.
The technique from Code formatter version 2
you can adapt to other use case in string split because you can clarify array index after split string and re-formatter use the functional programming.