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











댓글

이 블로그의 인기 게시물

Lesson 12_1 프로퍼티 노드(Property Node)

DAQ로 전압 측정하기-2

Lesson 12_2 참조를 이용한 프로퍼티노드(Property Node)