Skip to main content
Module

x/drash/tests/deps.ts>Drash.Request#bodyParam

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

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.