Невозможно получить HttpHeaderResponse - PullRequest
0 голосов
/ 16 июня 2019

У меня проблема с моим угловым приложением, так как я не могу получить данные в HttpResponseHeader. это мой ответ:

enter image description here

мой сервисный код:

getUsers(page?: number, itemsPerPage?: number): Observable<PaginatedResult<User[]>> {
    const url = this.baseUrl + '/users/';
    const paginatedResult: PaginatedResult<User[]> = new PaginatedResult<User[]>();

    let params = new HttpParams();
    if (page != null && itemsPerPage != null) {

        params = new HttpParams()
                         .set('pageNumber', page.toString())
                         .set('pageSize', itemsPerPage.toString());

    }
    return this.http.get<User[]>(this.baseUrl + '/users', { observe: 'response', params})
        .pipe(
            map(response => {
                paginatedResult.result = response.body;
                if (response.headers.get('Pagination') != null) {
                    paginatedResult.pagination = JSON.parse(response.headers.get('Pagination'));
                }
                return paginatedResult;
            })
         );
}

в конфигурации Cors Backend я сделал:

app.UseCors(p=>p.AllowAnyHeader().AllowAnyMethod().AllowCredentials());

enter image description here

1 Ответ

1 голос
/ 17 июня 2019

Вы ошиблись в названии ключа заголовка.Переименуйте ваши «Accoss-Control-Expose-Headers» в «Access-Control-Expose-Headers»

...