Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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}`);
 
PREVIOUS NEXT
Tagged: #Get #url #parse #deprecated #solved
ADD COMMENT
Topic
Name
4+8 =