Allow to setFullResponse per request
See original GitHub issueI generally like extracting the data
field of my API responses. However, sometimes (only) I need to access headers of a particular request. Currently, I’m doing it like:
Restangular.setFullResponse(true).all('user').getList()
.then(function(response){
Restangular.setFullResponse(false);
totalUsers = response.headers('X-Total-Count');
currentPageUsers = response.data;
});
But if there are other simultaneous Restangular requests, they may fail as they expect no full response. Ability to set the full response per request would solve the problem.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Access-Control-Allow-Methods - HTTP - MDN Web Docs
The Access-Control-Allow-Methods response header specifies one or more methods allowed when accessing a resource in response to a preflight ...
Read more >How can I capture all network requests and full response data ...
You can enable a request interception with page.setRequestInterception() for each request, and then, inside page.on('request') , you can use ...
Read more >Advanced Usage — Requests 2.28.1 documentation
Whenever you receive a Response object from an API call or a Session call, the request attribute is actually the PreparedRequest that was...
Read more >HTTP/1.1: Method Definitions
This allows user agents to represent other methods, such as POST, PUT and DELETE, ... The response to a GET request is cacheable...
Read more >HTTP Request Response Headers Tutorial In Detail - YouTube
In this tutorial you will learn about HTTP Request and response headers from basics in detail. I have exlain http request and http...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case someone stumbles on this thread, you can do something like this now for a single request using
setFullResponse
:@poppahorse a follow up to this. The above code results in the same problem as the OPs - the global setFullResponse is set as each request goes out, so the value may not be correct depending on the timing of the responses.
The solution, as far as I can see is use addResponseInterceptor instead, as the response is parsed straight afterwards. For the original case: