Module

x/drash/mod.ts>Request#pathParam

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

Get a path parameter from the request based on the request's URL and the resource path it matched to.

Examples

Example 1

// Assume a path for your resource is "/users/:id/:city?", and the request
// is "/users/2/".
const id = this.paramParam("id") // Returns 2
const city = this.queryParam("city") // Returns undefined

Parameters

name: string
  • The parameter name in the resource path.

Returns

string | undefined

The value for the parameter if found, or undefined if not set.