Represents an HTTP response to be sent to a client.
This type is used to define the structure of an HTTP response. It includes necessary information such as status code, response headers, and an optional response body.
const httpResponse: HttpResponse = { status: 200, body: 'Hello, world!', headers: { 'Content-Type': 'text/plain', 'Cache-Control': 'no-cache' }};This defines a typical HTTP response with a 200 OK status, a plain text body, andheaders for content type and cache control. Copy
const httpResponse: HttpResponse = { status: 200, body: 'Hello, world!', headers: { 'Content-Type': 'text/plain', 'Cache-Control': 'no-cache' }};This defines a typical HTTP response with a 200 OK status, a plain text body, andheaders for content type and cache control.
Optional
A string containing the body of the response. Optional.
An object representing the HTTP headers. Keys are header names, values are the corresponding header values.
A numeric HTTP status code
Represents an HTTP response to be sent to a client.
This type is used to define the structure of an HTTP response. It includes necessary information such as status code, response headers, and an optional response body.
Example