URL

URLSearchParams.get()

Looks up the first query value for a name. Tested on Node.js 22.16.0. An empty value differs from an absent key. Use getAll for repeated values.

Formal Syntax & Structure

nodejs syntaxnodejs
params.get(name)

Parameters & Attributes

NameTypeDescription
namestringParameter name.

Return Value

string | null

First value or null if absent.

Working Example

Example Snippetnodejs
import { URL, URLSearchParams, fileURLToPath, pathToFileURL } from 'node:url';const p=new URLSearchParams('tag=a&tag=b&empty=');console.log(JSON.stringify([p.get('tag'),p.get('empty'),p.get('none')]));
Node.js Reference