url.parse deprecated
// Get the url and parse
const myUrl = new URL(req.url, "http://localhost:3000/");
// Get url path
const path = myUrl.pathname;
const trimmedPath = path.replace(/^\/+|\/+$/g, "");
url.parse deprecated
// Get the url and parse
const myUrl = new URL(req.url, "http://localhost:3000/");
// Get url path
const path = myUrl.pathname;
const trimmedPath = path.replace(/^\/+|\/+$/g, "");
Get the url and parse or url.parse deprecated solved
// Get the url and parse
// const parsedUrl = url.parse(req.url, true); --> This is deprecated
const myUrl = new URL(req.url, "http://localhost:3000/"); // Use this instead
// Get the path of the url
const path = myUrl.pathname;
const trimmedPath = path.replace(/\/+|\/+&/g, "");
console.log(`Request is received on path: ${trimmedPath}`);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us