NodeJs Tutorials
- NodeJs
- Install NodeJs
- Why use NodeJs
- NodeJs Process Model
- create First Application
- Run NodeJs Application
- Node.js Console
- Node.Js Modules
- URL Modules
- node.js Callback
- Node.js Events
- Upload Files
- Upload single & Multiple Files
- NodeJs File System
- NodeJs Email
- Debugging NodeJs
- .ENV
- NodeJs Mysql
- Helpers
- encription and decription in nodeJs
- Query string
- Date & Time
- Express Js
- Template Engine with Express
- MVC Pattern in Node.Js
- list of NPM Module
- Middleware
- Body Parser
- Render
- Nodemon module
- Morgan module
- Flash Message in ExpressJs
- Session
- Session store in database
- Cookies
- Helmet
- Multer
- Router: How To Use Routing In Node.Js
- App.Js
- express.json() and express.urlencoded()
- REST APIs in NodeJs
- Gloabal Objects
- Submit Form Data
- How to get Post Data in Node.js
- How to Get URL Parameters in Node.js
- How to create Node Project
- How to Insert Form Data Into the MySql Table Using Node.js
- How to fetch Data from MySQL database table using Node.js
- CRUD Example
- Await and Async
- Promises
- Login Example
- Password Encription
- How to validate Form (Form Validation) in Node.Js?
- Registration & Login form usingn Node.Js & MySql?
- Forgot & Reset Password
- File Upload in Node.Js with ExpressJs
- Resize Image Before Upload using Multer Sharp
- Upload multiple file using node.js with multer module
- Upload file using node.js with multer module
- Client IP Address
- REST API Downloading File in NodeJs
- Export and Download CSV From MySQL Database
- CRUD REST API
- CRUD REST API Example 2
- Enable HTTPS using Node
- How to send EMAIL using NodeJs?
- Dynamic dependent dropdown using NodeJs?
- Autocomplete Search
- Get and Send Data From Ajax Request
- Get and Post Data using Ajax
- Passport Authentication
- Node Js Data type
- Node Js Error
- Node Js Array Function
- Node Js String Function
- Puppeter Module
What is URL module in Node.Js?
Url module is the core modules of node.js, which is used to parse the URL and its other properties.
The URL module splits up a web address into readable parts. To include the URL module, use the require() method:
an HTTP server will require information from the request URL to accurately process a request. This request URL is located on the url property contained within the req object itself.
var url = require('url');
Parse an address with the url.parse() method, and it will return a URL object with each part of the address as properties:
Example
File Name : example.js
var url = require('url');
var adr = 'http://localhost:8080/default.htm?year=2022&month=April';
var q = url.parse(adr, true);
console.log(q.host); //returns 'localhost:8080'
console.log(q.pathname); //returns '/default.htm'
console.log(q.search); //returns '?year=2022&month=april'
var qdata = q.query; //returns an object: { year: 2022, month: 'April' }
console.log(qdata.month); //returns 'April'
Example :-
File Name : url_test.js
var http = require('http');
var url = require('url');
http.createServer(function (req, res) {
var queryString = url.parse(req.url, true);
console.log(queryString);
// console.log("Complete href is :-"+queryString.href);
}).listen(8080);
Example
File Name :
var http = require('http');
var url = require('url');
http.createServer(function (req, res) {
var queryString = url.parse(req.url,true);
queryString.href = "www.ittutorial.in/xyz.html";
console.log("Complete href is :-"+queryString.href);
}).listen(8080);
File Name :
File Name :