Node.js urlObject.auth API
Last Updated :
31 Mar, 2023
With the help of urlObject.auth() method, we can find the authentication parameter within the hostname. This method returns the string of parameters.
Syntax :
urlObject.auth()
Return: Returns the string of authentication parameters.
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
const url = require( 'url' );
const adr =
const q = url.parse(adr, true );
console.log(q.auth);
|
Output:
Example 2: In this example with the help of urlObject.auth() method we are able to extract the username and password from the hostname.
javascript
const url = require( 'url' );
const adr =
const q = url.parse(adr, true );
console.log(q.search);
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...