What is the best way to implement a conversion from date string to date object for each service the request data from server? Lets say I have a userService that fetch some users from database. each user implements this interface :
export interface UserAccountInformation {
id: string,
email: string,
companyName?: string,
phoneNumber?: string,
firstName?: string,
lastName?: string,
country?: string,
zipCode?: string,
creationDate: Date
}
But when receiving the user on the client the creationDate is a string and not an object. I know it can be changed from the service, but I wonder if there is a general solution for all services using maybe a regex on the request response? Is this a good idea to use something like that?
new Date(userAccountInformation.creationDate)?Dateyou will experience with other custom classes.