Task.ts:
export class Task {
name: string;
dueDate: Date;
}
tasks.service.ts:
@Injectable()
export class TasksService {
constructor(private http: HttpClient) { }
getTasks(): Observable<Task[]> {
return this.http.get<Task[]>(`${WEBAPI_URL}/Tasks`);
}
}
The Task
objects I get back from getTasks()
have their dueDate
field assigned but the value is of type string
instead of Date
like I would expect.
Some searching lead me to this issue on the Angular github which made clear to me that HttpClient has no intent of properly parsing my object. Unfortunately the issue didn't give helpful guidance about what I should actually be doing to get my Date
object. What do I do?