“url.Parse veraltet” Code-Antworten

url.Parse veraltet

  // 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, "");
Encouraging Eel

Holen Sie sich die URL und analysieren Sie oder URL.Parse veraltet gelöst

  // 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}`);
Anxious Alpaca

Ähnliche Antworten wie “url.Parse veraltet”

Fragen ähnlich wie “url.Parse veraltet”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen