Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
Why is http req.url giving two arrays instead of one?

I am using some code that looks like this since my instructor has forbidden us from using the URL module:

let http = require('http');
    http.createServer(function (req, res) {
        let request=req.url.split('/');
        
        console.log(request);
    }).listen(5000);
}

However, this prints two arrays instead of 1, for the URL

http://127.0.0.1:5000/translate/e2s/this+is+the+url

these look like:

[ '', 'translate', 'e2s', 'this+is+the+url' ]
[ '', 'favicon.ico' ]

I can't index these because they behave as a single array so if I do request[3].split('+') for instance, I get an error.

Why is this happening and how can I fix this?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda