javascript
Published on January 26, 2024By DeveloperBreeze
// Import 'url' and 'querystring' modules
const url = require('url');
const querystring = require('querystring');
// Example request URL
const requestUrl = 'http://example.com/api?param1=value1¶m2=value2';
// Parse the URL
const parsedUrl = url.parse(requestUrl);
// Parse and retrieve query parameters
const queryParams = querystring.parse(parsedUrl.query);
// Log the parsed query parameters
console.log('Query Parameters:', queryParams);
Comments
Please log in to leave a comment.