Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Not assigning returned API data to data property? #61

Closed
chrisnicola opened this issue Oct 28, 2016 · 1 comment
Closed

Not assigning returned API data to data property? #61

chrisnicola opened this issue Oct 28, 2016 · 1 comment

Comments

@chrisnicola
Copy link

There does not seem to be a simple way to override the data property of returned API data. My API doesn't wrap the returned data in a object property in this way.

I could use overrides but that seems more involved than necessary for such a minor change, or is it? Maybe I'm just misunderstanding this.

@wardbell
Copy link
Contributor

wardbell commented Oct 29, 2016

I agree. Added responseInterceptor to new v.0.1.14 in commit e423d57

You should be able to do anything you want to the response including change the shape of the body.

Example in example/hero-data.service.ts:

 // intercept response from the default HTTP method handlers
  responseInterceptor(response: ResponseOptions, reqInfo: RequestInfo) {
    const method = RequestMethod[reqInfo.req.method].toUpperCase();
    const body = JSON.stringify(response.body);
    console.log(`responseInterceptor: ${method} ${reqInfo.req.url}: \n${body}`);
    return response;
  }

Only called for the default HTTP handlers. Ignored if you override any of these methods.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants