VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-http-clientrequest-settimeout-method/

⇱ Node.js http.ClientRequest.setTimeout() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js http.ClientRequest.setTimeout() Method

Last Updated : 27 Jan, 2023

The http.ClientRequest.setTimeout() is an inbuilt application programming interface of class ClientRequest within the HTTP module which is used to set the request time out for the client request.

Syntax:

request.setTimeout(timeout[, callback])

Parameters: This method takes the time out value as a parameter in milliseconds, and the second parameter is the callback function that executes after the given timeout value.

Return Value: This method returns nothing but a callback function for further operation.

Example 1: Filename-index.js

 
 Run the index.js file using the following command:

node index.js

Output:

timeout

Example 2: Filename-index.js

Run the index.js file using the following command:

node index.js

Output:

timeout

Reference: https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_request_settimeout_timeout_callback

Comment

Explore