Response object
The response object is almost identical to the request object. It is created when a request receives an answer from the server. Response objects also have headers and a body, the same object types as request objects.
Responses are normally created by the platform when a response is received from the server. However, you can create a new response. This is more common when you want to transform a response.
A scenario I have dealt with is accessing data from an older API that returned flat data. The flat data needed to be transformed into a multi-dimensional JSON object. Instead of repeating that CPU intensive process, I transformed the data and cached the transformed response.
The Response constructor has two parameters, a Body ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access