I'm encountering a problem when trying to convert a JSON response into an object. All the properties of my object are being treated as strings, is that normal?
Below is my AJAX request:
public fetchSingle = (keys: any[]): Observable<Medal> => {
return this._http.get(this.actionUrl + this.getKeyURL(keys))
.map((response: Response) => response.json() as Medal )
.catch(this.handleError);
}
This is how my medal model looks like:
export interface Medal {
medalNumber: number;
awardingOrganization: string;
dateAwarded: Date;
}
And here is where I encounter the issue with the string conversion:
this._medalService.fetchSingle(this.ids).subscribe(
(medal: Medal) => {
console.log(typeof(medal.dateAwarded)); // <-- returning string and not Date
},
error => console.log(error);
});