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

188
Views
Node not running in expected order

Please excuse the beginner level question here, but on day 2 of Google searching and trying every permutation I can still not making progress on understanding why things are running the order they are.

Given the following code:

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})

var username = await rl.question("Pleaser enter username\n");


await axios
  .get('https://somewhere.net/api/something/', {
    headers: {
      Username: username
    }
  })
  .then(res => {
    console.log('statusCode: '+ res.status)
    console.log(res.data.response)
  })
  .catch(error => {
    console.error(error)
  })
  rl.close();

Why am I getting a Username undefined before it even prompts the user for input? I would expect to ask the user for input, then run the axios.

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!