node.js url
Please read how to initialize npm from this post.
The reference is 'https://nodejs.org/dist/latest-v14.x/docs/api/url.html'.
1. require
const url = require('url');
2. Create url
const myUrl = new URL('http://example_website.com:5000/helloWorld.html?id=25&status=active');
myUrl type is Object.
console.log(typeof myUrl , myUrl);
3. get information from url
console.log(myUrl.href);
console.log(myUrl.origin);
console.log(myUrl.protocol);
console.log(myUrl.host);
console.log(myUrl.hostname);
console.log(myUrl.search);
console.log(myUrl.searchParams);
// ... etc
댓글
댓글 쓰기