![]() |
VOOZH | about |
The http.ClientRequest.setHeader() is an inbuilt application programming interface of class ClientRequest within the HTTP module which is used to set the object of the header.
Syntax:
const request.setHeader(name, value)
Parameters: This method takes the name and value of the particular header as a parameter as key-value pair.
Return Value: This method has nothing to return.
Example 1: Filename-index.js
Run the index.js file using the following command:
node index.js
Output:
before operation :- text/html after operation :- undefined
Example 2: Filename-index.js
Run the index.js file using the following command:
node index.js
Output:
before operation :- type=ninja,language=javascript after operation :- undefined
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_request_setheader_name_value