Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!