URLSearchParams.prototype.set - Node documentation
method URLSearchParams.prototype.set

Usage in Deno

import { URLSearchParams } from "node:url";
URLSearchParams.prototype.set(
name: string,
value: string,
): void

Sets the value in the URLSearchParams object associated with name tovalue. If there are any pre-existing name-value pairs whose names are name, set the first such pair's value to value and remove all others. If not, append the name-value pair to the query string.

const params = new URLSearchParams();
params.append('foo', 'bar');
params.append('foo', 'baz');
params.append('abc', 'def');
console.log(params.toString());
// Prints foo=bar&foo=baz&abc=def

params.set('foo', 'def');
params.set('xyz', 'opq');
console.log(params.toString());
// Prints foo=def&abc=def&xyz=opq

Parameters

name: string
value: string

Return Type

void