request
The request global object contains information about the incoming HTTP request. It is read-only and available in every script.
Properties
| Property | Type | Description |
|---|---|---|
request.method | string | HTTP method (GET, POST, PUT, DELETE, etc.) |
request.uri | string | Full request URI including query string |
request.path | string | Path without query string |
request.query | object | Parsed query string parameters |
request.headers | object | Request headers (lowercase keys) |
request.body | string | Raw request body |
request.cookies | object | Parsed cookies |
request.method
The HTTP method as an uppercase string.
if (request.method === "POST") {
// Handle form submission
}
request.uri
The full URI as requested by the client, including the query string.
// For: /search?q=hello&page=2
request.uri // "/search?q=hello&page=2"
request.path
The path portion of the URI without the query string.
// For: /search?q=hello
request.path // "/search"
request.query
An object containing parsed query string parameters. All values are strings.
// For: /page?name=Alice&age=30
request.query.name // "Alice"
request.query.age // "30"
request.headers
An object containing the request headers. Keys are lowercase with hyphens.
request.headers["content-type"] // "application/json"
request.headers["host"] // "example.com"
request.headers["user-agent"] // "Mozilla/5.0 ..."
request.body
The raw request body as a string. Typically used with POST and PUT requests.
if (request.method === "POST") {
const data = JSON.parse(request.body);
// Process data
}
request.cookies
An object containing cookies sent by the client.
const theme = request.cookies.theme || "light";
const token = request.cookies.auth_token;