URLSearchParams.append() method in Node.js

Updated

The urlSearchParams.append() is an inbuilt application programming interface of class URLSearchParams with in url module which is used to append the associate argument of name to value in this url search params object. Syntax :

urlSearchParams.append(name, value)

Parameter: This method accepts the following argument as a parameter.

  • name : name of the argument.
  • value : value for the particular argument.

Return Value :

This method has nothing to return. Below programs illustrates the use of urlSearchParams.append() Method: Example 1: 

// node program to demonstrate the 
// URLSearchParams.append API as Setter 
 
//importing the module 'url'
const http = require('url');

// creating and intializing URLSearchParams object
const params = new URLSearchParams();

// appending value in the object
// by using append() api
params.append('A', 'Book');
params.append('B', 'Pen');
params.append('C', 'Pencile');

//display the result
console.log(params.toString());


// appending value in the object
// by using append() api
params.set('A', 'Taj');
params.set('C', 'Mahal');

// display the result
console.log("\n" +params.toString());

Output :

A=Book&B=Pen&C=Pencile

A=Taj&B=Pen&C=Mahal

Example 2 :

// node program to demonstrate the 
// URLSearchParams.append API as Setter 
 
//importing the module 'url'
const http = require('url');

// creating and intializing URLSearchParams object
const params = new URLSearchParams();

// appending value in the object
// by using append() api
params.append('A', 'Book');
params.append('B', 'Pen');
params.append('C', 'Pencile');

//display the result
console.log(params.toString());

Output :  

A=Book&B=Pen&C=Pencile

Note : The above program will not run on online JavaScript and script editor . Reference: https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_urlsearchparams_append_name_value

Comment
Mithlesh Upadhyay Published 9 Nov 2026 · 2 min read

Mithlesh Upadhyay is a Computer Science and AI expert from Madhya Pradesh with strong academic background (BE in CSE and M.Tech in AI) and over six years of experience in technical content development. He has contributed tech articles, led teams, and worked in Full Stack Development and Data Science. He founded the w3colleges.org portal for learning resources.

Related tutorials

  • Readable, writable and duplex streams in Node.js

    A stream in Node is simply a sequence of bytes. A stream contains a buffer of bytes, and this buffer has a zero or greater length. In Node,…

    3 min read
  • Strict mode in JavaScript

    For a long time, JavaScript had no compatibility issues because in every new version release old functionality were not changing. But it was not good as if there…

    2 min read
  • Code structure in JavaScript: Semicolon and Comment

    Semicolons and Comments are buidling blocks of code. Semicolons We can have as many statements in our code as we want. Statements can be separated with a semicolon.…

    3 min read
  • Hello, world! in JavaScript

    In this part of the tutorial, we will learn on core JavaScript. We need working environment o run our scripts. We will use either IDE or browser to…

    4 min read
  • Developer console in web browsers

    Code is prone to errors, and as a human, it’s natural to make mistakes. In the browser, errors are not visible to users by default, which makes it…

    2 min read
  • JavaScript Manuals and specifications

    This is a tutorial designed to help you learn the language gradually, but you’ll eventually need additional resources. 1. Specification The ECMA-262 specification is the most detailed and…

    2 min read