Issue
I try in Angular to recover 'x-pagination' informations from my WEB Api (with http get method).
Data are well present in the web api response as you can see below (from browser panel).
I do my get request in Angular like this :
public getAll(pageNumber: number, pageSize: number){
const api: string = this.apiAddress `truckParameters?PageNumber=${pageNumber}&PageSize=${pageSize}`;
const httpOptions = { headers: new HttpHeaders({'x-pagination': 'application/json'}),
observe: 'response' as 'response'};
return this.httpClient.get(api, httpOptions).subscribe(
(response) => {
console.info('Header :' + JSON.stringify(response.headers.get('x-pagination'), null, 4));
}
);
}
I can read "cache-control","content-length" and "content-type" but I'm not able to read the "x-pagination" informations.
What I'm doing bad?
Solution
The solution was to expose the custom header in the "Startup" file of my Asp .net Core Web Api.
Thereby, Angular can read the "x-pagination" header element.
For more informations : Enabling Custom Header with CORS Configured
Answered By - EICE
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.