Add an option to return the raw response.
Closes #3391668
Merge request reports
Activity
- Resolved by Pratik Kamble
- Resolved by Pratik Kamble
- Resolved by Coby Sher
For the test cases, you can check that what is returned from
get
isinstanceof Response
. You can also check thatresponse.headers
andresponse.status
exists.For the msw handlers, you can setup handlers that return different status codes on arbitrary urls for any new things you want to setup, but you should be able to use the existing ones too.
added 13 commits
-
b2098cb9...620f69bc - 9 commits from branch
project:canary
- c98d30c5 - Add an option to return the raw response.
- 9af9d28a - 3393652: Updates to send raw response.
- 74829817 - 3393652: Adds unit test for raw reponse.
- 7d104d06 - 3391668: Adds tsdoc comment for rawResponse parameter.
Toggle commit list-
b2098cb9...620f69bc - 9 commits from branch
- Resolved by Brian Perry
The code that is here looks good, but I'm not sure that this is the best API for this. While I'm sure there are some cases where a developer may only want the raw response, I feel like the more common case is that they would want the raw response, along with the data that this client typically provides. Since they have the raw response, they can get whatever they need, but they now have to do it themselves and lose out of all of the other features of the client.
Thinking of our caching use case in the Pantheon starter kits - don't we need both the response headers and the data from the client? Could be missing something, but with this API it seems like we'd need to either get the raw response and do most of the work that the client does ourselves, or make a second uncached response to the API.
What if
rawResponse
(might need a new name in this case) instead returned an object that had both -{ response, json }
. If we did that, one of those would have to be a copy of the original response since the stream can only be read once.Thoughts?
Edited by Brian Perry
added 7 commits
-
7d104d06...4eb10900 - 6 commits from branch
project:canary
- ca889c2b - Merge branch 'canary' into 3391668-add-raw-response
-
7d104d06...4eb10900 - 6 commits from branch
added 1 commit
- ea18fefe - Update rawResponse object to the format { response, json }
- Resolved by Coby Sher
added 1 commit
- 366762d6 - Update example based on feedback and add changeset