Parsing URL-encoded Form Data
The Parse Data middleware parses URL-encoded form data and converts the values into their appropriate types.
Example
Request:
fetch("/form", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: "string=example&number=42"
})
Server-side:
import v from "vkrun"
const vkrun = v.App()
vkrun.post("/form", (request: v.Request, response: v.Response) => {
console.log(request.body)
// Output: { string: "example", number: 42 }
response.status(200).end()
})
In this example:
"example"
remains a string."42"
is converted to a number.