Node.js URL.origin API
Last Updated :
14 Oct, 2021
url.origin is an inbuilt application programming interface(API) of the URL class within the url module.
url.origin API is used to gets the read-only serialization of the URL’s origin.
Syntax: url.origin
url : It is an object created by URL constructor.
Example 1:
javascript
const url = require( 'url' );
console.log(URL_1.origin);
|
Output:
Note: We can not set the origin of URL using url.origin API. If we try to do it then it will be ignored and origin will not be effected.
Example 2:
javascript
const url = require( 'url' );
console.log(URL_1.origin);
console.log(URL_1.origin);
|
Output:
Share your thoughts in the comments
Please Login to comment...