Skip to main content
Module

x/drash/mod.ts>Request#bodyParam

A microframework for Deno's HTTP server with zero third-party dependencies
Go to Latest
method Request.prototype.bodyParam
import { Request } from "https://deno.land/x/drash@v2.7.0/mod.ts";

Get a body parameter of the request by the name

Examples

Example 1

// Assume you've sent a fetch request with:
//   {
//     user: {
//       name: "Drash"
//     }
//   }
const user = request.bodyParam<{ name: string }>("user") // { name: "Drash" }
// More examples:
request.bodyParam<BodyFile[]>('uploads')

Parameters

name: string

The body parameter name

Returns

T | undefined

The value of the parameter if found, or undefined if not found.