I've got an Angular 6 application that makes calls to Web API controllers that use EF Core. By default, EF Core will not load foreign entities (lazy loading maybe?), so following suggestions, I used the following code to include such entities:
var members = await _context.Person.Include(x => x.PersonNavigation).Where(x => x.DepartmentId == id).ToListAsync();
The problem is, when the controller returns members, it sends a header of:
Transfer-Encoding: chunked
Making the result/data unreadable by my Angular application (to be expected I guess, since the response is chunked).
Any suggestions? Is this standard behavior by Web API? What can I do to return a viable JSON?
Thanks
Edit #1, per johnny 5 request:
API Controller:
public async Task<IActionResult> GetDepartmentMembers([FromRoute] int id)
{
var members = await _context.Person.Include(x => x.PersonNavigation).Where(x => x.DepartmentId == id).ToListAsync();
if (members == null) { return NotFound(); }
return Ok(members);
}
Angular Service:
getDepartmentMembers(departmentId: number): Observable<Person[]> {
return this.http.get<Person[]>('http://localhost:49659/api/departments/' + departmentId + '/members');
}
Angular Component:
getDepartmentMembers(departmentId: number) {
this.departmentService.getDepartmentMembers(departmentId).subscribe(data => {
this.departmentMembers = data;
});
}
Response Headers: