PARSE DATA
Query Parameters

Parsing Query Parameters

Query parameters in URLs are automatically parsed and converted by the Parse Data middleware.

Example

Request:

fetch("/query?string=value&integer=123&boolean=true")

Server-side:

import v from "vkrun"
 
const vkrun = v.App()
 
vkrun.get("/query", (request: v.Request, response: v.Response) => {
  console.log(request.query)
  // Output: { string: "value", integer: 123, boolean: true }
  response.status(200).end()
})

In this example:

  • "value" remains a string.
  • "123" is converted to a number.
  • "true" is converted to a boolean.
Copyright © 2024 MIT by Mario Elvio