angular / angular/angular

httpResource: Allow parse to access headers

Open
#66,636 4 comments 5 reactions 0 assignees View on GitHub
area: common/http
Dominant language
TypeScript
Stars
101k
Forks
27.5k
Avg merge
1d 19h
Merged PRs (30d)
288

Description

### Which @angular/* package(s) are relevant/related to the feature request?

common

### Description

I have the situation where the server sends additional information in der headers, eg count information for a list. Unfortunately it seems, that `parse` cannot access the headers.

### Proposed solution

Provide access to headers as additional argument in parse:
```
{
parse: (value, headers) => [ value, headers.get('X-Count') ?? 0]
}
```

### Alternatives considered

An interceptor provided for the `HttpResourceRequest` could do the transformation as well.

Contributor guide

Open the contributing guide

Research direction

Start in the common package by tracing the httpResource parse callback and the HttpResourceRequest flow to determine where response headers are available. Update the parse contract so headers can be accessed, and add coverage showing that a header such as X-Count reaches the callback and can affect the parsed result.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.