Skip to content
Related Articles

Related Articles

Node | urlObject.auth API
  • Last Updated : 24 Feb, 2021

With the help of urlObject.auth() method, we can find the authentication parameter within the hostname. This method return the string of parameters.
 

Syntax : urlObject.auth() 
Return : Returns the string of authentication parameter. 
 

Example #1 : In this example with the help of urlObject.auth() method we are able to extract the username and password from the hostname.
 

javascript




// importing the module 'url'
const url = require('url');
   
var adr =
 
// Parse the address:
var q = url.parse(adr, true);
 
/* The parse method returns an object containing
 URL properties */
console.log(q.auth);


Output : 
 



Example #2 :
 

javascript




// importing the module 'url'
const url = require('url');
   
var adr =
 
// Parse the address:
var q = url.parse(adr, true);
 
/* The parse method returns an object containing
 URL properties */
console.log(q.search);


Output : 
 

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :